Package uk.ac.starlink.util
Class WrapUtils
java.lang.Object
uk.ac.starlink.util.WrapUtils
Utilities relating to the
Wrapper class.- Since:
- 3 Apr 2008
- Author:
- Mark Taylor
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectgetWrapped(Object obj) Returns the object on which a given object is based.static ObjectgetWrapped(Object obj, Class<?> clazz) Attempts to return an object of a given class on which a given object is based.
-
Method Details
-
getWrapped
Returns the object on which a given object is based. Ifobjis aWrapper, it is unwrapped as far as possible and the base object is returned. Otherwiseobjitself is returned.- Parameters:
obj- test object- Returns:
- ultimate base object of
obj
-
getWrapped
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 classclazzis found, at which point it is returned. If noclazzobject can be found,nullis returned.- Parameters:
obj- test object- Returns:
- object within the wrapping hierarchy of class
clazz, or null
-