Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.util
Class Objects

    java.lang.Object
      org.jboss.util.Objects

public final class Objects
extends Object

A collection of `Object` utilities.

Version:
  `$Revision: 1.1 $`
Author:
  Jason Dillon

Constructor Summary
`Objects()`

Method Summary
`static Object` | `coerce(Object[] values, Class type)` Coerce the given values into the specified type.
`static Object` | `coerce(Object value, Class type)` Coerce the given value into the specified type.
`static Object` | `copy(Serializable obj)` Copy an serializable object deeply.
`static Object` | `deref(Object obj)` Dereference the given object if it is non-null and is an instance of `Reference`.
`static boolean` | `equals(Object[] a, Object[] b)` Test the equality of two object arrays.
`static boolean` | `equals(Object[] a, Object[] b, boolean deep)` Test the equality of two object arrays.
`static Constructor` | `getCompatibleConstructor(Class type, Class valueType)` Get a compatible constructor for the given value type
`static boolean` | `isArray(Object obj)` Check if the given object is an array (primitve or native).
`static Object[]` | `toArray(Object obj)` Return an Object array for the given object.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Objects

    public Objects()

Method Detail

### getCompatibleConstructor

    public static Constructor getCompatibleConstructor(Class type,
                                                       Class valueType)

  Get a compatible constructor for the given value type

  Parameters:
    `type` - Class to look for constructor in
    `valueType` - Argument type for constructor
  Returns:
    Constructor or null

### coerce

    public static Object coerce(Object value,
                                Class type)
                         throws CoercionException

  Coerce the given value into the specified type.

  Parameters:
    `value` - Value to coerce.
    `type` - Class type to coerce to.
  Returns:
    Coerced object.

    Primative classes will be translated into their respective wrapper class as needed.

  Throws:
    `NotCoercibleException` - Value is not corecible.
    `CoercionException` - Failed to coerce.

### coerce

    public static Object coerce(Object[] values,
                                Class type)
                         throws CoercionException

  Coerce the given values into the specified type.

  If type is an array, then an array of that type is returned else the first element from values is used.

  Coerce will handle primative array types correctly by using the reflection mechanism to unwrap primative values from their wrapper classes.

  Parameters:
    `values` - Values to coerce.
    `type` - Class type to coerce object to.
  Returns:
    Coerced object.
  Throws:
    `NotCoercibleException` - Value is not corecible.
    `CoercionException` - Failed to coerce.
    `IllegalArgumentException` - Indexed value is null (values contains a null element).

### copy

    public static Object copy(Serializable obj)
                       throws IOException,
                              ClassNotFoundException

  Copy an serializable object deeply.

  Parameters:
    `obj` - Object to copy.
  Returns:
    Copied object.
  Throws:
    `IOException`
    `ClassCastException`
    `ClassNotFoundException`

### deref

    public static Object deref(Object obj)

  Dereference the given object if it is non-null and is an instance of `Reference`. If the object is null then null is returned. If the object is not an instance of `Reference`, then the object is returned.

  Parameters:
    `obj` - Object to dereference.
  Returns:
    Dereferenced object.

### isArray

    public static boolean isArray(Object obj)

  Check if the given object is an array (primitve or native).

  Parameters:
    `obj` - Object to test.
  Returns:
    True of the object is an array.

### toArray

    public static Object[] toArray(Object obj)

  Return an Object array for the given object.

  Parameters:
    `obj` - Object to convert to an array. Converts primitive arrays to Object arrays consisting of their wrapper classes. If the object is not an array (object or primitve) then a new array of the given type is created and the object is set as the sole element.

### equals

    public static boolean equals(Object[] a,
                                 Object[] b,
                                 boolean deep)

  Test the equality of two object arrays.

  Parameters:
    `a` - The first array.
    `b` - The second array.
    `deep` - True to traverse elements which are arrays.
  Returns:
    True if arrays are equal.

### equals

    public static boolean equals(Object[] a,
                                 Object[] b)

  Test the equality of two object arrays.

  Parameters:
    `a` - The first array.
    `b` - The second array.
  Returns:
    True if arrays are equal.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 JBoss Group, LLC. All Rights Reserved.