Class MetadataFactory
java.lang.Object
com.vaadin.featurepack.data.jpacontainer.metadata.MetadataFactory
Factory for creating and populating
ClassMetadata and
EntityClassMetadata instances.- Since:
- 1.0
- Author:
- Petter Holmström (Vaadin Ltd)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected PersistentPropertyMetadata.AccessTypedetermineAccessType(Class<?> type) protected voidextractPropertiesFromFields(Class<?> type, ClassMetadata<?> metadata) protected voidextractPropertiesFromMethods(Class<?> type, ClassMetadata<?> metadata) <T> ClassMetadata<T> getClassMetadata(Class<T> mappedClass, PersistentPropertyMetadata.AccessType accessType) Extracts the class metadata frommappedClass.<T> EntityClassMetadata<T> getEntityClassMetadata(Class<T> mappedClass) Extracts the entity class metadata frommappedClass.static MetadataFactoryGets the singleton instance of this factory.protected booleanprotected booleanprotected booleanprotected booleanprotected voidloadProperties(Class<?> type, ClassMetadata<?> metadata, PersistentPropertyMetadata.AccessType accessType)
-
Constructor Details
-
MetadataFactory
protected MetadataFactory()
-
-
Method Details
-
getInstance
Gets the singleton instance of this factory.- Returns:
- the factory instance (never null).
-
getEntityClassMetadata
public <T> EntityClassMetadata<T> getEntityClassMetadata(Class<T> mappedClass) throws IllegalArgumentException Extracts the entity class metadata frommappedClass. The access type (field or method) will be determined from the location of theIdorEmbeddedIdannotation. If both of these are missing, this method will fail. This method will also fail ifmappedClasslacks theEntityannotation.- Parameters:
mappedClass- the mapped class (must not be null).- Returns:
- the class metadata.
- Throws:
IllegalArgumentException- if no metadata could be extracted.
-
getClassMetadata
public <T> ClassMetadata<T> getClassMetadata(Class<T> mappedClass, PersistentPropertyMetadata.AccessType accessType) throws IllegalArgumentException Extracts the class metadata frommappedClass. IfmappedClassisEmbeddable, the result will be an instance ofClassMetadata. IfmappedClassis anEntity, the result will be an instance ofEntityClassMetadata.accessTypeinstructs the factory where to look for annotations and which defaults to assume if there are no annotations.- Parameters:
mappedClass- the mapped class (must not be null).accessType- the location where to look for annotations (must not be null).- Returns:
- the class metadata.
- Throws:
IllegalArgumentException- if no metadata could be extracted.
-
loadProperties
protected void loadProperties(Class<?> type, ClassMetadata<?> metadata, PersistentPropertyMetadata.AccessType accessType) -
determineAccessType
-
isReference
-
isCollection
-
isEmbedded
-
extractPropertiesFromFields
-
isElementCollection
-
extractPropertiesFromMethods
-