|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jsefa.common.annotation.TypeMappingFactory<N,R>
N
- the type of the data type nameR
- the type of the type mapping registrypublic abstract class TypeMappingFactory<N,R extends TypeMappingRegistry<N>>
Abstract super class for factories which can create TypeMapping
s from annotated classes.
All subclasses should be thread-safe.
Nested Class Summary | |
---|---|
protected class |
TypeMappingFactory.TypeMappingPlaceholder
A placeholder for a type mapping used during the construction of a type mapping, i. e. between calling prepareToCreate(Class, Object) and the registration of the type mapping. |
Constructor Summary | |
---|---|
TypeMappingFactory(R typeMappingRegistry,
SimpleTypeConverterProvider simpleTypeConverterProvider,
ValidatorProvider validatorProvider,
ObjectAccessorProvider objectAccessorProvider)
Constructs a new TypeMappingFactory . |
Method Summary | |
---|---|
protected void |
assertHasSimpleType(Class<?> objectType)
Asserts that a given object type is a simple type. |
protected void |
assertNoCollectionType(Class<?> objectType)
Asserts that a given object type is not a collection class. |
protected void |
assertTypeMappingExists(N dataTypeName)
Asserts that a type mapping exists for the given data type name. |
protected void |
assertTypeMappingIsSimple(N dataTypeName)
Asserts that a type mapping exists for the given data type name and is simple. |
abstract N |
createIfAbsent(Class<?> objectType)
Creates a type mapping for the given object type, registers it with the type mapping registry and returns its data type name. |
protected SimpleTypeConverter |
createSimpleTypeConverter(Class<?> objectType,
Field field,
Annotation annotation)
Creates a simple type converter. |
protected abstract N |
getAnnotatedDataTypeName(Annotation annotation,
Class<?> annotationContextClass)
Returns the data type name as declared through the given annotation. |
protected Class<?> |
getCollectionItemType(Annotation annotation,
Field field,
boolean fromFieldDeclarationAllowed)
Returns the type of the items of a collection. |
protected Class<?> |
getMapKeyType(Annotation annotation,
Field field)
Returns the type of the keys of a map. |
protected Class<?> |
getMapValueType(Annotation annotation,
Field field,
boolean fromFieldDeclarationAllowed)
Returns the type of the values of a map. |
protected ObjectAccessorProvider |
getObjectAccessorProvider()
Returns the object accessor provider. |
protected SimpleTypeConverterProvider |
getSimpleTypeConverterProvider()
Returns the simple type converter provider. |
R |
getTypeMappingRegistry()
Returns the type mapping registry. |
protected ValidatorFactory |
getValidatorFactory()
Returns the validator factory. |
protected ValidatorProvider |
getValidatorProvider()
Returns the validator provider. |
protected boolean |
hasCollectionType(Class<?> objectType)
Returns true if and only if the given object type is a collection type. |
protected boolean |
hasMapType(Class<?> objectType)
Returns true if and only if the given object type is a map type. |
protected boolean |
hasSimpleType(Class<?> objectType)
Returns true if and only if the given object type is a simple type. |
protected boolean |
prepareToCreate(Class<?> objectType,
N dataTypeName)
Called before creating a new type mapping with the given data type name for the given object type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TypeMappingFactory(R typeMappingRegistry, SimpleTypeConverterProvider simpleTypeConverterProvider, ValidatorProvider validatorProvider, ObjectAccessorProvider objectAccessorProvider)
TypeMappingFactory
.
typeMappingRegistry
- the type mapping registry. New types will be registered using that registry.simpleTypeConverterProvider
- the simple type converter provider to usevalidatorProvider
- the validator provider to useobjectAccessorProvider
- the object accessor provider to useMethod Detail |
---|
public abstract N createIfAbsent(Class<?> objectType)
objectType
- the object type to create a type mapping for.
public final R getTypeMappingRegistry()
protected final boolean prepareToCreate(Class<?> objectType, N dataTypeName)
The purpose of this method is to prevent from creating duplicates and from falling in an endless loop in case of a cycle in the type mapping graph.
In case the method returns true, a TypeMappingFactory.TypeMappingPlaceholder
is registered so that object type
information can be retrieved during the construction of a type mapping. That type mapping is replaced by the
real type mapping after finishing its construction.
objectType
- the object typedataTypeName
- the data type name
protected final ObjectAccessorProvider getObjectAccessorProvider()
protected final SimpleTypeConverterProvider getSimpleTypeConverterProvider()
protected final ValidatorProvider getValidatorProvider()
protected final SimpleTypeConverter createSimpleTypeConverter(Class<?> objectType, Field field, Annotation annotation)
objectType
- the object type to create a converter forfield
- the field to create a converter for. May be null.annotation
- the annotation providing parameters for constructing the converter. May be null.
protected final Class<?> getCollectionItemType(Annotation annotation, Field field, boolean fromFieldDeclarationAllowed)
annotation
- the annotation of the fieldfield
- the fieldfromFieldDeclarationAllowed
- true, if the field is a collection which contains only values of one type so
that the type may be deduced from the actual parameter type of the parameterized type of the field; false
otherwise.
protected final Class<?> getMapValueType(Annotation annotation, Field field, boolean fromFieldDeclarationAllowed)
annotation
- the annotation of the fieldfield
- the fieldfromFieldDeclarationAllowed
- true, if the field is a map which contains only values of one type so
that the type may be deduced from the actual parameter type of the parameterized type of the field; false
otherwise.
protected final Class<?> getMapKeyType(Annotation annotation, Field field)
annotation
- the annotation of the fieldfield
- the field
protected abstract N getAnnotatedDataTypeName(Annotation annotation, Class<?> annotationContextClass)
annotation
- the annotationannotationContextClass
- the context class of the annotation. This class may be needed to interpret the
annotation data.
protected final ValidatorFactory getValidatorFactory()
protected final boolean hasSimpleType(Class<?> objectType)
objectType
- the object type
protected final boolean hasCollectionType(Class<?> objectType)
objectType
- the object type
protected final boolean hasMapType(Class<?> objectType)
objectType
- the object type
protected final void assertTypeMappingExists(N dataTypeName)
dataTypeName
- the data type name.
AnnotationException
- if the assertion fails.protected final void assertTypeMappingIsSimple(N dataTypeName)
dataTypeName
- the data type name.
AnnotationException
- if the assertion fails.protected final void assertNoCollectionType(Class<?> objectType)
objectType
- the object type to check
AnnotationException
- if the assertion fails.protected final void assertHasSimpleType(Class<?> objectType)
objectType
- the object type to check
AnnotationException
- if the assertion fails.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |