|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tapestry5.ioc.internal.util.InternalUtils
public class InternalUtils
Utilities used within various internal implementations of the tapestry-ioc module.
Field Summary | |
---|---|
static Mapper<Class,AnnotationProvider> |
CLASS_TO_AP_MAPPER
|
static Mapper<ObjectCreator,Object> |
CREATE_OBJECT
|
static Mapper<Method,AnnotationProvider> |
METHOD_TO_AP_MAPPER
|
static AnnotationProvider |
NULL_ANNOTATION_PROVIDER
|
static boolean |
SERVICE_CLASS_RELOADING_ENABLED
|
Constructor Summary | |
---|---|
InternalUtils()
|
Method Summary | ||
---|---|---|
static
|
addToMapList(Map<K,List<V>> map,
K key,
V value)
Adds a value to a specially organized map where the values are lists of objects. |
|
static String |
asString(Method method)
Converts a method to a user presentable string consisting of the containing class name, the method name, and the short form of the parameter list (the class name of each parameter type, shorn of the package name portion). |
|
static String |
asString(Method method,
PlasticProxyFactory proxyFactory)
Converts a method to a user presentable string using a PlasticProxyFactory to obtain a Location
(where possible). |
|
static ObjectCreator[] |
calculateParameters(ObjectLocator locator,
InjectionResources resources,
Class[] parameterTypes,
Type[] genericTypes,
Annotation[][] parameterAnnotations,
OperationTracker tracker)
|
|
static ObjectCreator[] |
calculateParametersForMethod(Method method,
ObjectLocator locator,
InjectionResources resources,
OperationTracker tracker)
|
|
static String |
capitalize(String input)
Capitalizes a string, converting the first character to uppercase. |
|
static void |
close(Closeable stream)
|
|
static boolean |
containsSymbols(String input)
Return true if the input string contains the marker for symbols that must be expanded. |
|
static
|
createConstructorConstructionPlan(OperationTracker tracker,
ObjectLocator locator,
InjectionResources resources,
org.slf4j.Logger logger,
String description,
Constructor<T> constructor)
|
|
static
|
createMethodInvocationPlan(OperationTracker tracker,
ObjectLocator locator,
InjectionResources resources,
org.slf4j.Logger logger,
String description,
Object instance,
Method method)
|
|
static
|
findAnnotation(Annotation[] annotations,
Class<T> annotationClass)
Finds a specific annotation type within an array of annotations. |
|
static Constructor |
findAutobuildConstructor(Class clazz)
Searches a class for the "best" constructor, the public constructor with the most parameters. |
|
static Method |
findMethod(Class containingClass,
String methodName,
Class... parameterTypes)
|
|
static
|
get(Map<K,V> map,
K key)
Gets a value from a map (which may be null). |
|
static String |
getServiceId(AnnotatedElement annotated)
Extracts the service id from the passed annotated element. |
|
static void |
injectIntoFields(Object object,
ObjectLocator locator,
InjectionResources resources,
OperationTracker tracker)
Injects into the fields (of all visibilities) when the Inject or
InjectService annotations are present. |
|
static boolean |
isBlank(String input)
Returns true if the input is null, or is a zero length string (excluding leading/trailing whitespace). |
|
static boolean |
isEmptyCollection(Object input)
Returns true if the input is an empty collection. |
|
static boolean |
isLocalFile(Class clazz)
Determines if the indicated class is stored as a locally accessible file (and not, typically, as a file inside a JAR). |
|
static boolean |
isNonBlank(String input)
|
|
static boolean |
isStatic(Method method)
Returns true if the method provided is a static method. |
|
static String |
join(List elements)
Joins together some number of elements to form a comma separated list. |
|
static String |
join(List elements,
String separator)
Joins together some number of elements. |
|
static String |
joinSorted(Collection elements)
Creates a sorted copy of the provided elements, then turns that into a comma separated list. |
|
static
|
keys(Map<K,V> map)
|
|
static String |
lastTerm(String input)
Searches the string for the final period ('.') character and returns everything after that. |
|
static Location |
locationOf(Object location)
Sniffs the object to see if it is a Location or Locatable . |
|
static
|
matchAndSort(Collection<? extends T> collection,
Predicate<T> predicate)
|
|
static long |
nextUUID()
Generates a unique value for the current execution of the application. |
|
static Object[] |
realizeObjects(ObjectCreator[] creators)
|
|
static
|
reverseIterator(List<T> list)
|
|
static int |
size(Collection collection)
|
|
static int |
size(Object[] array)
Returns the size of an object array, or null if the array is empty. |
|
static List<String> |
sortedKeys(Map map)
Extracts the string keys from a map and returns them in sorted order. |
|
static String |
stripMemberName(String memberName)
Strips leading "_" and "$" and trailing "_" from the name. |
|
static AdvisorDef2 |
toAdvisorDef2(AdvisorDef advisor)
|
|
static AnnotationProvider |
toAnnotationProvider(Class element)
|
|
static AnnotationProvider |
toAnnotationProvider(Method element)
|
|
static ContributionDef2 |
toContributionDef2(ContributionDef contribution)
|
|
static ContributionDef3 |
toContributionDef3(ContributionDef contribution)
|
|
static DecoratorDef2 |
toDecoratorDef2(DecoratorDef decorator)
|
|
static List<String> |
toList(Enumeration e)
Converts an enumeration (of Strings) into a sorted list of Strings. |
|
static
|
toMapper(Coercion<S,T> coercion)
Wraps a Coercion as a Mapper . |
|
static String |
toMessage(Throwable exception)
Extracts the message from an exception. |
|
static ModuleDef2 |
toModuleDef2(ModuleDef md)
|
|
static MethodAdvice |
toPlasticMethodAdvice(MethodAdvice iocMethodAdvice,
AnnotationProvider methodAnnotationProvider)
Converts old-style Tapestry IoC MethodAdvice to modern
Plastic MethodAdvice . |
|
static ServiceDef2 |
toServiceDef2(ServiceDef sd)
|
|
static ServiceDef3 |
toServiceDef3(ServiceDef sd)
|
|
static ServiceLifecycle2 |
toServiceLifecycle2(ServiceLifecycle lifecycle)
|
|
static void |
validateConstructorForAutobuild(Constructor constructor)
|
|
static void |
validateMarkerAnnotation(Class markerClass)
Validates that the marker annotation class had a retention policy of runtime. |
|
static void |
validateMarkerAnnotations(Class[] markerClasses)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean SERVICE_CLASS_RELOADING_ENABLED
public static AnnotationProvider NULL_ANNOTATION_PROVIDER
public static final Mapper<Class,AnnotationProvider> CLASS_TO_AP_MAPPER
public static final Mapper<Method,AnnotationProvider> METHOD_TO_AP_MAPPER
public static Mapper<ObjectCreator,Object> CREATE_OBJECT
Constructor Detail |
---|
public InternalUtils()
Method Detail |
---|
public static String asString(Method method, PlasticProxyFactory proxyFactory)
PlasticProxyFactory
to obtain a Location
(where possible). asString(Method)
is used under the covers, to present a detailed, but not excessive,
description of the class, method and parameters.
method
- method to convert to a stringproxyFactory
- used to obtain the Location
public static String asString(Method method)
method
-
public static int size(Object[] array)
public static int size(Collection collection)
public static String stripMemberName(String memberName)
public static List<String> toList(Enumeration e)
public static <T extends Annotation> T findAnnotation(Annotation[] annotations, Class<T> annotationClass)
T
- annotations
- to searchannotationClass
- to match
public static ObjectCreator[] calculateParametersForMethod(Method method, ObjectLocator locator, InjectionResources resources, OperationTracker tracker)
public static ObjectCreator[] calculateParameters(ObjectLocator locator, InjectionResources resources, Class[] parameterTypes, Type[] genericTypes, Annotation[][] parameterAnnotations, OperationTracker tracker)
public static void injectIntoFields(Object object, ObjectLocator locator, InjectionResources resources, OperationTracker tracker)
Inject
or
InjectService
annotations are present.
object
- to be initializedlocator
- used to resolve external dependenciesresources
- provides injection resources for fieldstracker
- track operationspublic static String join(List elements)
public static String join(List elements, String separator)
elements
- objects to be joined togetherseparator
- used between elements when joiningpublic static String joinSorted(Collection elements)
public static boolean isBlank(String input)
public static boolean isEmptyCollection(Object input)
public static boolean isNonBlank(String input)
public static String capitalize(String input)
public static Location locationOf(Object location)
Location
or Locatable
. Returns null if null or not
convertable to a location.
public static List<String> sortedKeys(Map map)
map
- the map to extract keys from (may be null)
public static <K,V> Set<K> keys(Map<K,V> map)
public static <K,V> V get(Map<K,V> map, K key)
K
- V
- map
- the map to extract from (may be null)key
-
public static boolean isStatic(Method method)
public static <T> Iterator<T> reverseIterator(List<T> list)
public static boolean containsSymbols(String input)
public static String lastTerm(String input)
public static Constructor findAutobuildConstructor(Class clazz)
Inject
, it will be used (no check for multiple such
constructors is made, only at most a single constructor should have the annotation).
clazz
- to search for a constructor for
public static <K,V> void addToMapList(Map<K,List<V>> map, K key, V value)
K
- the type of keyV
- the type of the listmap
- to store value intokey
- for which a value is addedvalue
- to addpublic static void validateMarkerAnnotation(Class markerClass)
markerClass
- the marker annotation classpublic static void validateMarkerAnnotations(Class[] markerClasses)
public static void close(Closeable stream)
public static String toMessage(Throwable exception)
exception
- to extract message from
public static void validateConstructorForAutobuild(Constructor constructor)
public static AnnotationProvider toAnnotationProvider(Class element)
public static final Method findMethod(Class containingClass, String methodName, Class... parameterTypes)
public static ServiceDef3 toServiceDef3(ServiceDef sd)
public static ServiceDef2 toServiceDef2(ServiceDef sd)
public static ModuleDef2 toModuleDef2(ModuleDef md)
public static ServiceLifecycle2 toServiceLifecycle2(ServiceLifecycle lifecycle)
public static <T extends Comparable<T>> List<T> matchAndSort(Collection<? extends T> collection, Predicate<T> predicate)
public static ContributionDef2 toContributionDef2(ContributionDef contribution)
public static ContributionDef3 toContributionDef3(ContributionDef contribution)
public static AdvisorDef2 toAdvisorDef2(AdvisorDef advisor)
public static DecoratorDef2 toDecoratorDef2(DecoratorDef decorator)
public static boolean isLocalFile(Class clazz)
public static <S,T> Mapper<S,T> toMapper(Coercion<S,T> coercion)
Coercion
as a Mapper
.
public static long nextUUID()
public static String getServiceId(AnnotatedElement annotated)
ServiceId
annotation is checked.
If present, its value is returned. Otherwise Named
annotation is checked. If present, its value is
returned.
If neither of the annotations is present, null
value is returned
annotated
- annotated element to get annotations frompublic static MethodAdvice toPlasticMethodAdvice(MethodAdvice iocMethodAdvice, AnnotationProvider methodAnnotationProvider)
MethodAdvice
to modern
Plastic MethodAdvice
.
iocMethodAdvice
- old style advice
public static AnnotationProvider toAnnotationProvider(Method element)
public static <T> ObjectCreator<T> createConstructorConstructionPlan(OperationTracker tracker, ObjectLocator locator, InjectionResources resources, org.slf4j.Logger logger, String description, Constructor<T> constructor)
public static <T> ObjectCreator<T> createMethodInvocationPlan(OperationTracker tracker, ObjectLocator locator, InjectionResources resources, org.slf4j.Logger logger, String description, Object instance, Method method)
public static Object[] realizeObjects(ObjectCreator[] creators)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |