Package cz.cvut.kbss.jopa.utils
Class EntityPropertiesUtils
java.lang.Object
cz.cvut.kbss.jopa.utils.EntityPropertiesUtils
Utility class for entity properties.
- 
Method SummaryModifier and TypeMethodDescriptiongetAllFields(Class<?> cls) Gets all instance fields of the specified class, including inherited ones.static ObjectgetAttributeValue(FieldSpecification<?, ?> attribute, Object instance) Gets value of the specified attribute.static ObjectgetFieldValue(Field field, Object instance) Gets value of the specified field from the specified instance.static URIgetIdentifier(Object entity, Metamodel metamodel) Extracts primary key from the specifiedentityand returns it.static <T> URIgetIdentifier(T entity, EntityType<?> et) Extracts entity's identifier according to the specified entity type.static URIgetValueAsURI(Object value) Transforms the specified value to URI (if possible).static booleanisFieldStatic(Field field) Returns true if the specified field is static.static booleanisFieldTransient(Field field) Checks whether the specified field should not be persisted, i.e.static voidsetFieldValue(Field field, Object instance, Object value) Sets value of the specified field.static <T> voidsetIdentifier(Object identifier, T entity, EntityType<T> et) Sets the specified identifier on the specified entity.static voidverifyIdentifierIsGenerated(Object instance, EntityType<?> entityType) Verifies, that the primary key (identifier) of the specified instance is generated.
- 
Method Details- 
getIdentifierExtracts primary key from the specifiedentityand returns it.- Parameters:
- entity- The entity to extract primary key from
- metamodel- Metamodel
- Returns:
- IRI of the entity or null if it is not set
- Throws:
- NullPointerException- If- entityor- metamodelis null
- OWLPersistenceException- If- entityis not an entity or if the identifier is of an unknown type
 
- 
setFieldValueSets value of the specified field.- Parameters:
- field- Field to set value on
- instance- Target instance (can be- nullfor static fields)
- value- The value to set (can be- null)
 
- 
getFieldValueGets value of the specified field from the specified instance.- Parameters:
- field- Field to get value of
- instance- Instance that contains the field
- Returns:
- Field value
 
- 
getAttributeValueGets value of the specified attribute.- Parameters:
- attribute- Attribute to extract value of
- instance- Instance from which value will be extracted
- Returns:
- Attribute value
 
- 
getIdentifierExtracts entity's identifier according to the specified entity type.- Type Parameters:
- T- Type of the entity
- Parameters:
- entity- Entity
- et- Entity type
- Returns:
- Identifier of the specified entity, possibly null
 
- 
setIdentifierSets the specified identifier on the specified entity.- Type Parameters:
- T- Type of the entity
- Parameters:
- identifier- The identifier to set
- entity- Target entity
- et- Entity type
 
- 
getValueAsURITransforms the specified value to URI (if possible).- Parameters:
- value- The value to transform
- Returns:
- URI
- Throws:
- NullPointerException- If- valueis- null
- IllegalArgumentException- If- valuecannot be transformed to URI
 
- 
getAllFieldsGets all instance fields of the specified class, including inherited ones.- Parameters:
- cls- The class to search
- Returns:
- List of declared fields
 
- 
verifyIdentifierIsGeneratedVerifies, that the primary key (identifier) of the specified instance is generated.If not, an exception is thrown. - Parameters:
- instance- The instance to verify
- entityType- Entity type of the instance, as specified by metamodel
- Throws:
- IdentifierNotSetException- If the identifier is not generated
 
- 
isFieldTransientChecks whether the specified field should not be persisted, i.e. whether it is transient in the persistence sense.A field is transient if it is: - static
- or final
- or transient
- or annotated with the Transientannotation
 - Parameters:
- field- The field to investigate
- Returns:
- Whether the field is transient
 
- 
isFieldStaticReturns true if the specified field is static.- Parameters:
- field- The field to check
- Returns:
- True if field is static, false otherwise
 
 
-