public final class TypeManufacturerUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
private static org.slf4j.Logger |
LOG
The application logger
|
| Modifier | Constructor and Description |
|---|---|
private |
TypeManufacturerUtil()
Non instantiable.
|
| Modifier and Type | Method and Description |
|---|---|
static Type[] |
fillTypeArgMap(Map<String,Type> typeArgsMap,
Class<?> pojoClass,
Type[] genericTypeArgs)
Fills type agruments map
|
static AttributeStrategy<?> |
findAttributeStrategy(DataProviderStrategy strategy,
List<Annotation> annotations,
Class<?> attributeType)
It returns a
AttributeStrategy if one was specified in
annotations, or null otherwise. |
static Integer |
findCollectionSize(DataProviderStrategy strategy,
List<Annotation> annotations,
Class<?> collectionElementType,
Holder<AttributeStrategy<?>> elementStrategyHolder,
Holder<AttributeStrategy<?>> keyStrategyHolder)
Searches for annotation with information about collection/map size
and filling strategies
|
static Object |
getTypeValue(DataProviderStrategy strategy,
org.springframework.messaging.MessageChannel channel,
AttributeMetadata attributeMetadata,
String qualifier)
Obtains a type value
|
static Object |
getTypeValueForGenericTypes(DataProviderStrategy strategy,
org.springframework.messaging.MessageChannel channel,
AttributeMetadata attributeMetadata,
Type genericAttributeType,
Map<String,Type> genericTypesArgumentsMap,
String qualifier)
Obtains a type value
|
static boolean |
isWrapper(Class<?> candidateWrapperClass)
It returns
true if this class is a wrapper class, false
otherwise |
static Type[] |
mergeActualAndSuppliedGenericTypes(Type[] actualTypes,
Type[] suppliedTypes,
Map<String,Type> typeArgsMap)
Utility to merge actual types with supplied array of generic type
substitutions
|
static Type[] |
mergeTypeArrays(Type[] original,
Type[] extra)
Utility method to merge two arrays
|
static Collection<? super Object> |
resolveCollectionType(Class<?> collectionType,
Collection<? super Object> defaultValue)
|
static Class<?> |
resolveGenericParameter(Type paramType,
Map<String,Type> typeArgsMap,
AtomicReference<Type[]> methodGenericTypeArgs)
It resolves generic parameter type
|
static Map<? super Object,? super Object> |
resolveMapType(Class<?> mapType,
Map<? super Object,? super Object> defaultValue)
It manufactures and returns a default instance for each map type
|
static Object |
returnAttributeDataStrategyValue(Class<?> attributeType,
AttributeStrategy<?> attributeStrategy)
It retrieves the value for the
PodamStrategyValue annotation with
which the attribute was annotated |
public static Object getTypeValue(DataProviderStrategy strategy, org.springframework.messaging.MessageChannel channel, AttributeMetadata attributeMetadata, String qualifier)
strategy - The Data Provider strategychannel - The Message Channel where to send/receive the message for the required valueattributeMetadata - The AttributeMetadata informationqualifier - The class of the requested typepublic static Object getTypeValueForGenericTypes(DataProviderStrategy strategy, org.springframework.messaging.MessageChannel channel, AttributeMetadata attributeMetadata, Type genericAttributeType, Map<String,Type> genericTypesArgumentsMap, String qualifier)
strategy - The Data Provider strategychannel - The Message Channel where to send/receive the message for the required valueattributeMetadata - The AttributeMetadata informationgenericAttributeType - The generic attribute typequalifier - The class of the requested type @return The type valuepublic static AttributeStrategy<?> findAttributeStrategy(DataProviderStrategy strategy, List<Annotation> annotations, Class<?> attributeType) throws InstantiationException, IllegalAccessException
AttributeStrategy if one was specified in
annotations, or null otherwise.annotations - The list of annotationsattributeType - Type of attribute expected to be returnedAttributeStrategy, if PodamStrategyValue or bean
validation constraint annotation was found among annotationsIllegalAccessException - if attribute strategy cannot be instantiatedInstantiationException - if attribute strategy cannot be instantiatedpublic static Type[] fillTypeArgMap(Map<String,Type> typeArgsMap, Class<?> pojoClass, Type[] genericTypeArgs)
This method places required and provided types for object creation into a map, which will be used for type mapping.
typeArgsMap - a map to fillpojoClass - Typed classgenericTypeArgs - Type arguments provided for a generics object by callerIllegalStateException - If number of typed parameters doesn't match number of
provided generic typespublic static Integer findCollectionSize(DataProviderStrategy strategy, List<Annotation> annotations, Class<?> collectionElementType, Holder<AttributeStrategy<?>> elementStrategyHolder, Holder<AttributeStrategy<?>> keyStrategyHolder) throws InstantiationException, IllegalAccessException
annotations - a list of annotations to inspectcollectionElementType - a collection element typeelementStrategyHolder - a holder to pass found element strategy back to the caller,
can be nullkeyStrategyHolder - a holder to pass found key strategy back to the caller,
can be nullInstantiationException - A strategy cannot be instantiatedIllegalAccessException - A strategy cannot be instantiatedpublic static boolean isWrapper(Class<?> candidateWrapperClass)
true if this class is a wrapper class, false
otherwisecandidateWrapperClass - The class to checktrue if this class is a wrapper class, false
otherwisepublic static Type[] mergeActualAndSuppliedGenericTypes(Type[] actualTypes, Type[] suppliedTypes, Map<String,Type> typeArgsMap)
actualTypes - an array of types used for field or POJO declarationsuppliedTypes - an array of supplied types for generic type substitutiontypeArgsMap - a map relating the generic class arguments ("<T, V>" for
example) with their actual typespublic static Type[] mergeTypeArrays(Type[] original, Type[] extra)
original - The main arrayextra - The additional array, optionally may be nullpublic static Collection<? super Object> resolveCollectionType(Class<?> collectionType, Collection<? super Object> defaultValue)
collectionType - The collection type *defaultValue - Default value for the collection, can be nullpublic static Class<?> resolveGenericParameter(Type paramType, Map<String,Type> typeArgsMap, AtomicReference<Type[]> methodGenericTypeArgs)
paramType - The generic parameter typetypeArgsMap - A map of resolved typesmethodGenericTypeArgs - Return value posible generic types of the generic parameter
typepublic static Map<? super Object,? super Object> resolveMapType(Class<?> mapType, Map<? super Object,? super Object> defaultValue)
The default implementation for a ConcurrentMap is
ConcurrentHashMap
The default implementation for a SortedMap is a TreeMap
The default Map is none of the above was recognised is a HashMap
mapType - The attribute type implementing MapdefaultValue - Default value for mappublic static Object returnAttributeDataStrategyValue(Class<?> attributeType, AttributeStrategy<?> attributeStrategy) throws IllegalArgumentException
PodamStrategyValue annotation with
which the attribute was annotatedattributeType - The attribute type, used for type checkingattributeStrategy - The AttributeStrategy to usePodamStrategyValue annotation with
which the attribute was annotatedIllegalArgumentException - If the type of the data strategy defined for the
PodamStrategyValue annotation is not assignable to
the annotated attribute. This de facto guarantees type
safety.Copyright © 2015. All rights reserved.