Class ClassMetadata<T>

java.lang.Object
com.vaadin.featurepack.data.jpacontainer.metadata.ClassMetadata<T>
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
EntityClassMetadata

public class ClassMetadata<T> extends Object implements Serializable
This class provides a way of accessing the JPA mapping metadata of Entity and Embeddable classes. This information may be used to construct queries or decide whether a property is sortable or not.
Since:
1.0
Author:
Petter Holmström (Vaadin Ltd)
See Also:
  • Method Details

    • getMappedClass

      public Class<T> getMappedClass()
      Gets the mapped class.
      Returns:
      the class (never null).
    • getPersistentProperties

      public Collection<PersistentPropertyMetadata> getPersistentProperties()
      Gets all the persistent properties of the class.
      Returns:
      an unmodifiable collection of property metadata.
    • getPersistentPropertyNames

      public Collection<String> getPersistentPropertyNames()
      Gets the names of all persistent properties of this class.
      Returns:
      an unmodifiable collection of property names.
      See Also:
    • getProperties

      public Collection<PropertyMetadata> getProperties()
      Gets all the properties of the class. In addition to the persistent properties, all public JavaBean properties are also included (even those who do not have setter methods).
      Returns:
      an unmodifiable collection of property metadata.
    • getPropertyNames

      public Collection<String> getPropertyNames()
      Gets the names of all the properties of this class.
      Returns:
      an unmodifiable collection of property names.
      See Also:
    • getProperty

      public PropertyMetadata getProperty(String propertyName)
      Gets the metadata of the named property.
      Parameters:
      propertyName - the name of the property (must not be null).
      Returns:
      the property metadata, or null if not found.
    • getPropertyValue

      protected Object getPropertyValue(T object, PropertyMetadata property) throws IllegalArgumentException
      Gets the value of property from object.
      Parameters:
      object - the object from which the property will be retrieved (must not be null).
      property - the metadata of the property (must not be null).
      Returns:
      the property value.
      Throws:
      IllegalArgumentException - if the property could not be retrieved.
    • setPropertyValue

      protected void setPropertyValue(T object, PropertyMetadata property, Object value) throws IllegalArgumentException
      Sets the value of property to value on object.
      Parameters:
      object - the object to which the property will be set (must not be null).
      property - the metadata of the property (must not be null).
      value - the property value.
      Throws:
      IllegalArgumentException - if the property could not be set.
    • getGetterMethod

      protected Method getGetterMethod(String propertyName, Class<?> parent)
      Gets the getter method for propertyName from parent.
      Parameters:
      propertyName - the JavaBean property name (must not be null).
      parent - the class from which to get the getter method (must not be null).
      Returns:
      the getter method, or null if not found.
    • getSetterMethod

      protected Method getSetterMethod(String propertyName, Class<?> parent, Class<?> propertyType)
      Gets the setter method for propertyName from parent.
      Parameters:
      propertyName - the JavaBean property name (must not be null).
      parent - the class from which to get the setter method (must not be null).
      propertyType - the type of the property (must not be null).
      Returns:
      the setter method, or null if not found.
    • getPropertyValue

      public Object getPropertyValue(T object, String propertyName) throws IllegalArgumentException
      Gets the value of object.propertyName. The property name may be nested.
      Parameters:
      object - the entity object from which the property value should be fetched (must not be null).
      propertyName - the name of the property (must not be null).
      Returns:
      the property value.
      Throws:
      IllegalArgumentException - if the property value could not be fetched, e.g. due to propertyName being invalid.
    • setPropertyValue

      public void setPropertyValue(T object, String propertyName, Object value) throws IllegalArgumentException, IllegalStateException
      Sets the value of object.propertyName to value. The property name may be nested.
      Parameters:
      object - the object whose property should be set (must not be null).
      propertyName - the name of the property to set (must not be null).
      value - the value to set.
      Throws:
      IllegalArgumentException - if the value could not be set, e.g. due to propertyName being invalid or the property being read only.
      IllegalStateException - if a nested property name is used and one of the nested properties (other than the last one) is null.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object