Package co.ecg.alpaca.core.framework
Class ObjectUtils
java.lang.Object
co.ecg.alpaca.core.framework.ObjectUtils
ObjectUtils class.
- Version:
- $Id: $Id
- Author:
- mkeathley
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindObjectRecursively
(Object object, Class<T> clazzToFind) Returns a list of instances of the Class requested anywhere in the parent objects hierarchy.flattenObject
(Object object) Flattens an iterable or map to its component entries or valuesgetAllInheritedFields
(Class<?> type) Returns all fields of the class that are declared by the type or any superclassstatic boolean
isWrapperType
(Class<?> clazz) Returns true if the class is a primitive wrapper type.
-
Constructor Details
-
ObjectUtils
public ObjectUtils()
-
-
Method Details
-
flattenObject
Flattens an iterable or map to its component entries or values- Parameters:
object
- The object to flatted- Returns:
- A set of objects contained by the object or a set of itself if not an iterable or map
- Throws:
IllegalAccessException
-
isWrapperType
Returns true if the class is a primitive wrapper type.- Parameters:
clazz
- The class to check- Returns:
- True IFF the class is a primitive wrapper
-
getAllInheritedFields
Returns all fields of the class that are declared by the type or any superclass- Parameters:
type
- The type to traverse- Returns:
- A List of Fields
-
findObjectRecursively
public static <T> Map<Class,List<T>> findObjectRecursively(Object object, Class<T> clazzToFind) throws IllegalAccessException Returns a list of instances of the Class requested anywhere in the parent objects hierarchy. This does not find instances that are transient, synthetic, static, or final.- Type Parameters:
T
- The type of the class to find- Parameters:
object
- The object to traverseclazzToFind
- The class of instances to find- Returns:
- A map of Classes in which the object was located and a list of found instances.
- Throws:
IllegalAccessException
- Thrown if a reflection error occurs
-