Class WrapUtils


  • public class WrapUtils
    extends java.lang.Object
    Utilities relating to the Wrapper class.
    Since:
    3 Apr 2008
    Author:
    Mark Taylor
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object getWrapped​(java.lang.Object obj)
      Returns the object on which a given object is based.
      static java.lang.Object getWrapped​(java.lang.Object obj, java.lang.Class clazz)
      Attempts to return an object of a given class on which a given object is based.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getWrapped

        public static java.lang.Object getWrapped​(java.lang.Object obj)
        Returns the object on which a given object is based. If obj is a Wrapper, it is unwrapped as far as possible and the base object is returned. Otherwise obj itself is returned.
        Parameters:
        obj - test object
        Returns:
        ultimate base object of obj
      • getWrapped

        public static java.lang.Object getWrapped​(java.lang.Object obj,
                                                  java.lang.Class clazz)
        Attempts to return an object of a given class on which a given object is based. An object is unwrapped (see Wrapper.getBase()) until an object of class clazz is found, at which point it is returned. If no clazz object can be found, null is returned.
        Parameters:
        obj - test object
        Returns:
        object within the wrapping hierarchy of class clazz, or null