com.vaadin.addon.jpacontainer.metadata
Class MetadataFactory

java.lang.Object
  extended by com.vaadin.addon.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 Summary
protected MetadataFactory()
           
 
Method Summary
protected  PersistentPropertyMetadata.AccessType determineAccessType(Class<?> type)
           
protected  void extractPropertiesFromFields(Class<?> type, ClassMetadata<?> metadata)
           
protected  void extractPropertiesFromMethods(Class<?> type, ClassMetadata<?> metadata)
           
<T> ClassMetadata<T>
getClassMetadata(Class<T> mappedClass, PersistentPropertyMetadata.AccessType accessType)
          Extracts the class metadata from mappedClass.
<T> EntityClassMetadata<T>
getEntityClassMetadata(Class<T> mappedClass)
          Extracts the entity class metadata from mappedClass.
static MetadataFactory getInstance()
          Gets the singleton instance of this factory.
protected  boolean isCollection(AccessibleObject ab)
           
protected  boolean isElementCollection(AccessibleObject ab)
           
protected  boolean isEmbedded(AccessibleObject ab)
           
protected  boolean isReference(AccessibleObject ab)
           
protected  void loadProperties(Class<?> type, ClassMetadata<?> metadata, PersistentPropertyMetadata.AccessType accessType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetadataFactory

protected MetadataFactory()
Method Detail

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)


Copyright © 2013 Vaadin Ltd. All rights reserved.