Package cz.cvut.kbss.jsonld.common
Class BeanClassProcessor
java.lang.Object
cz.cvut.kbss.jsonld.common.BeanClassProcessor
Reflection-related utilities.
- 
Method SummaryModifier and TypeMethodDescriptionstatic Collection<?>Creates collection of the specified type.static Collection<?>createCollection(Class<?> collectionType) Creates an instance of the specified collection type.static Collection<?>createCollection(Field field) Creates a collection to fill the specified field.static <T> TcreateInstance(Class<T> cls) Creates new instance of the specified class.static Class<?>getCollectionItemType(Field field) Determines the declared element type of collection represented by the specified field.static ObjectgetFieldValue(Field field, Object instance) Extracts value of the specified field, from the specified instance.static Class<?>getMapGenericValueType(Field field) In case the map represent by the specified field has as value another generic type, this method retrieves this generic type's actual first argument.static Class<?>getMapKeyType(Field field) Determines the declared type of keys of the map represented by the specified field.static Class<?>getMapValueType(Field field) Gets the declared type of values of the map represented by the specified field.static booleanisCollection(Field field) Checks whether the specified field represents a collection.static booleanisIdentifierType(Class<?> cls) Checks whether the specified type is a valid identifier type.static booleanisIndividualType(Class<?> cls) Checks whether the specified class represents an individual reference and not a complex object.static voidsetFieldValue(Field field, Object instance, Object value) Sets value of the specified field.static voidverifyPropertiesFieldType(Field field) Checks that the properties field is aMap.
- 
Method Details- 
getFieldValueExtracts value of the specified field, from the specified instance.- Parameters:
- field- The field to extract value from
- instance- Instance containing the field
- Returns:
- Field value, possibly null
 
- 
setFieldValueSets value of the specified field.- Parameters:
- field- The field to set
- instance- Instance on which the field will be set
- value- The value to use
 
- 
createInstanceCreates new instance of the specified class.- Type Parameters:
- T- The type of the created object
- Parameters:
- cls- The class to instantiate
- Returns:
- New instance
- Throws:
- BeanProcessingException- If the class is missing a public no-arg constructor
 
- 
createCollectionCreates collection of the specified type.- Parameters:
- type- Collection type
- Returns:
- New collection instance
 
- 
createCollectionCreates a collection to fill the specified field.I.e. the type of the collection is determined from the declared type of the field. - Parameters:
- field- The field to create collection for
- Returns:
- New collection instance
 
- 
createCollectionCreates an instance of the specified collection type.Lists and sets are supported. - Parameters:
- collectionType- Type of the collection
- Returns:
- New collection instance
 
- 
getCollectionItemTypeDetermines the declared element type of collection represented by the specified field.- Parameters:
- field- Field whose type is a collection
- Returns:
- Declared element type of the collection
 
- 
getMapKeyTypeDetermines the declared type of keys of the map represented by the specified field.- Parameters:
- field- Map field
- Returns:
- Declared type of values
 
- 
getMapValueTypeGets the declared type of values of the map represented by the specified field.- Parameters:
- field- Map field
- Returns:
- Declared type of values
 
- 
getMapGenericValueTypeIn case the map represent by the specified field has as value another generic type, this method retrieves this generic type's actual first argument.This implementation is supposed to determine value type of Propertiesfields with the following declarationMap<String, Collection<?>>, where the collection can be replaced by a more specific type (List, Set) and the map key type can be also different.- Parameters:
- field- Map field
- Returns:
- Value type if present, nullotherwise
 
- 
isCollectionChecks whether the specified field represents a collection.- Parameters:
- field- The field to examine
- Returns:
- Whether the field is a collection or not
 
- 
verifyPropertiesFieldTypeChecks that the properties field is aMap.- Parameters:
- field- The field to check
- Throws:
- TargetTypeException- When the field is not a Map
 
- 
isIndividualTypeChecks whether the specified class represents an individual reference and not a complex object.Individual references are identifiers or enum constants mapped to individuals. - Parameters:
- cls- Class to check
- Returns:
- truewhen the type represents an individual,- falseotherwise
- See Also:
 
- 
isIdentifierTypeChecks whether the specified type is a valid identifier type.- Parameters:
- cls- Class to check
- Returns:
- trueif the specified class can be used as identifier field type,- falseotherwise
- See Also:
- 
- PersistenceProperties.IDENTIFIER_TYPES
 
 
 
-