Package com.adobe.acs.commons.mcp.util
Class IntrospectionUtil
java.lang.Object
com.adobe.acs.commons.mcp.util.IntrospectionUtil
General introspection utilities
-
Method Summary
Modifier and TypeMethodDescriptionTry any available public constructors to create an object.static Class<?>getCollectionComponentType(Field field) Determine if the field is a list or array and return its component type if so.getDeclaredValue(AccessibleObject field) Determine the declared (default) value of a field; if a method is provided then an Empty optional is returned Note: This assumes that there is a public no-parameter constructor for the declaring object, otherwise this will return an empty optional.static booleanhasMultipleValues(Class clazz) Figure out if field represents multiple valuesstatic booleanisPrimitive(Field field) A primitive field is one which is a single or array/list of primitive values.static booleanA simple field is either primitive, an enumeration, or a string.
-
Method Details
-
hasMultipleValues
Figure out if field represents multiple values- Parameters:
clazz- Field to evaluate- Returns:
- true if field is an array or collection
-
getCollectionComponentType
Determine if the field is a list or array and return its component type if so.- Parameters:
field- Field to evaluate- Returns:
- List/Array component type or field type if not a list or array
-
isPrimitive
A primitive field is one which is a single or array/list of primitive values.- Parameters:
field- Field to evaluate- Returns:
- true if primitive or list/array of primitive values
-
isSimple
A simple field is either primitive, an enumeration, or a string.- Parameters:
field- Field to evaluate- Returns:
- true if primitive, an enumeration, or a string
-
createObject
Try any available public constructors to create an object. Return the first successful attempt.- Parameters:
c- Class to use- Returns:
- Optional object if successful, otherwise empty optional.
-
getDeclaredValue
Determine the declared (default) value of a field; if a method is provided then an Empty optional is returned Note: This assumes that there is a public no-parameter constructor for the declaring object, otherwise this will return an empty optional.- Parameters:
field- Field to evaluate- Returns:
- Optional with value if any found, otherwise empty optional is returned
-