Package uk.ac.starlink.util
Class WrapUtils
- java.lang.Object
-
- uk.ac.starlink.util.WrapUtils
-
public class WrapUtils extends java.lang.Object
Utilities relating to theWrapper
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.
-
-
-
Method Detail
-
getWrapped
public static java.lang.Object getWrapped(java.lang.Object obj)
Returns the object on which a given object is based. Ifobj
is aWrapper
, it is unwrapped as far as possible and the base object is returned. Otherwiseobj
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 (seeWrapper.getBase()
) until an object of classclazz
is found, at which point it is returned. If noclazz
object can be found,null
is returned.- Parameters:
obj
- test object- Returns:
- object within the wrapping hierarchy of class
clazz
, or null
-
-