Class ClassMetadata<T>
java.lang.Object
com.vaadin.featurepack.data.jpacontainer.metadata.ClassMetadata<T>
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
EntityClassMetadata
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 Summary
Modifier and TypeMethodDescriptionbooleanprotected MethodgetGetterMethod(String propertyName, Class<?> parent) Gets the getter method forpropertyNamefromparent.Gets the mapped class.Gets all the persistent properties of the class.Gets the names of all persistent properties of this class.Gets all the properties of the class.getProperty(String propertyName) Gets the metadata of the named property.Gets the names of all the properties of this class.protected ObjectgetPropertyValue(T object, PropertyMetadata property) Gets the value ofpropertyfromobject.getPropertyValue(T object, String propertyName) Gets the value ofobject.propertyName.protected MethodgetSetterMethod(String propertyName, Class<?> parent, Class<?> propertyType) Gets the setter method forpropertyNamefromparent.inthashCode()protected voidsetPropertyValue(T object, PropertyMetadata property, Object value) Sets the value ofpropertytovalueonobject.voidsetPropertyValue(T object, String propertyName, Object value) Sets the value ofobject.propertyNametovalue.
-
Method Details
-
getMappedClass
Gets the mapped class.- Returns:
- the class (never null).
-
getPersistentProperties
Gets all the persistent properties of the class.- Returns:
- an unmodifiable collection of property metadata.
-
getPersistentPropertyNames
Gets the names of all persistent properties of this class.- Returns:
- an unmodifiable collection of property names.
- See Also:
-
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
Gets the names of all the properties of this class.- Returns:
- an unmodifiable collection of property names.
- See Also:
-
getProperty
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 ofpropertyfromobject.- 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 ofpropertytovalueonobject.- 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
Gets the getter method forpropertyNamefromparent.- 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
Gets the setter method forpropertyNamefromparent.- 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
Gets the value ofobject.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 topropertyNamebeing invalid.
-
setPropertyValue
public void setPropertyValue(T object, String propertyName, Object value) throws IllegalArgumentException, IllegalStateException Sets the value ofobject.propertyNametovalue. 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 topropertyNamebeing 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
-
hashCode
public int hashCode()
-