Class ObjectUtils


  • public class ObjectUtils
    extends Object

    ObjectUtils class.

    Version:
    $Id: $Id
    Author:
    mkeathley
    • Constructor Detail

      • ObjectUtils

        public ObjectUtils()
    • 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 traverse
        clazzToFind - 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