public abstract class TypeManufacturerUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
private static org.slf4j.Logger |
LOG
The application logger
|
| Constructor and Description |
|---|
TypeManufacturerUtil() |
| 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 Type[] |
mergeActualAndSuppliedGenericTypes(Class<?> attributeType,
Type genericAttributeType,
Type[] suppliedTypes,
Map<String,Type> typeArgsMap)
Utility to merge actual types with supplied array of generic type
substitutions
|
static Class<?> |
resolveGenericParameter(Type paramType,
Map<String,Type> typeArgsMap,
AtomicReference<Type[]> methodGenericTypeArgs)
It resolves generic parameter type
|
static Object |
returnAttributeDataStrategyValue(Class<?> attributeType,
AttributeStrategy<?> attributeStrategy)
It retrieves the value for the
PodamStrategyValue annotation with
which the attribute was annotated |
public static AttributeStrategy<?> findAttributeStrategy(DataProviderStrategy strategy, List<Annotation> annotations, Class<?> attributeType) throws InstantiationException, IllegalAccessException
AttributeStrategy if one was specified in
annotations, or null otherwise.strategy - The data provider strategyannotations - 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
strategy - a data provider strategyannotations - 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 Type[] mergeActualAndSuppliedGenericTypes(Class<?> attributeType, Type genericAttributeType, Type[] suppliedTypes, Map<String,Type> typeArgsMap)
attributeType - actual type of objectgenericAttributeType - generic type of objectsuppliedTypes - 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 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 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 © 2016. All rights reserved.