Package uk.ac.starlink.util

# Class WrapUtils

java.lang.Object
uk.ac.starlink.util.WrapUtils

public class WrapUtils extends Object
Utilities relating to the `Wrapper` class.

Since:
  3 Apr 2008
Author:
  Mark Taylor

## Method Summary

Modifier and Type
Method
Description
`static Object`
`getWrapped(Object obj)`
Returns the object on which a given object is based.
`static Object`
`getWrapped(Object obj, 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 Details

### getWrapped

public static Object getWrapped(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 Object getWrapped(Object obj, 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