Class MetadataFactory

java.lang.Object
com.vaadin.featurepack.data.jpacontainer.metadata.MetadataFactory

public class MetadataFactory extends Object
Factory for creating and populating ClassMetadata and EntityClassMetadata instances.
Since:
1.0
Author:
Petter Holmström (Vaadin Ltd)
  • Constructor Details

    • MetadataFactory

      protected MetadataFactory()
  • Method Details

    • getInstance

      public static MetadataFactory 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 from mappedClass. The access type (field or method) will be determined from the location of the Id or EmbeddedId annotation. If both of these are missing, this method will fail. This method will also fail if mappedClass lacks the Entity annotation.
      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 from mappedClass. If mappedClass is Embeddable, the result will be an instance of ClassMetadata. If mappedClass is an Entity, the result will be an instance of EntityClassMetadata.

      accessType instructs 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

      protected PersistentPropertyMetadata.AccessType determineAccessType(Class<?> type)
    • isReference

      protected boolean isReference(AccessibleObject ab)
    • isCollection

      protected boolean isCollection(AccessibleObject ab)
    • isEmbedded

      protected boolean isEmbedded(AccessibleObject ab)
    • extractPropertiesFromFields

      protected void extractPropertiesFromFields(Class<?> type, ClassMetadata<?> metadata)
    • isElementCollection

      protected boolean isElementCollection(AccessibleObject ab)
    • extractPropertiesFromMethods

      protected void extractPropertiesFromMethods(Class<?> type, ClassMetadata<?> metadata)