Package co.ecg.alpaca.core.framework
Class ObjectUtils
- java.lang.Object
-
- co.ecg.alpaca.core.framework.ObjectUtils
-
public class ObjectUtils extends Object
ObjectUtils class.
- Version:
- $Id: $Id
- Author:
- mkeathley
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceObjectUtils.TriFunction<T,U,B,R>
-
Constructor Summary
Constructors Constructor Description ObjectUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Map<Class,Set<T>>findObjectRecursively(Object object, Class<T> clazzToFind)Returns a list of instances of the Class requested anywhere in the parent objects hierarchy.static Set<Object>flattenObject(Object object)Flattens an iterable or map to its component entries or valuesstatic List<Field>getAllInheritedFields(Class<?> type)Returns all fields of the class that are declared by the type or any superclassstatic booleanisWrapperType(Class<?> clazz)Returns true if the class is a primitive wrapper type.
-
-
-
Method Detail
-
flattenObject
public static Set<Object> flattenObject(Object object) throws IllegalAccessException
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
public static boolean isWrapperType(Class<?> clazz)
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
public static List<Field> getAllInheritedFields(Class<?> type)
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,Set<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
-
-