org.progeeks.util
Class ObjectUtils

java.lang.Object
  extended by org.progeeks.util.ObjectUtils

public class ObjectUtils
extends java.lang.Object

Some general object-level utility methods to aid in meta-programming and such.

Version:
$Revision: 1.10 $
Author:
Paul Speed

Constructor Summary
ObjectUtils()
           
 
Method Summary
static boolean areEqual(java.lang.Object o1, java.lang.Object o2)
          Returns true if the two objects are equal by reference or by .equals().
static void clearEquatableClasses()
          Clears the list of classes marked as equatable.
static void clearEquatableOverrides()
          Clears the list of instances marked as equatable.
static void clearEquatables()
          Clears both classes and instances that have been marked as equatable.
static java.lang.Object cloneObject(java.lang.Object obj)
          Clones the specified object if it is cloneable and has a public clone() method.
static java.util.List deepCloneList(java.util.List list)
          Deep clones a list, iterating and cloning each list element
static boolean isEquatable(java.lang.Class type)
          Returns true if the specified class or its hierarchy has its own .equals() method instead of inheriting one from Object.class.
static boolean isEquatable(java.lang.Object obj)
          Returns true if the class of the specified object implements its own .equals() method.
static void main(java.lang.String[] args)
           
static void markEquatable(java.lang.Class type)
          Manually marks a class as equatable for future checks by the isEquatable method.
static void markEquatable(java.lang.Object instance)
          Manually marks an instance as equatable for future checks by the isEquatable(Object) method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectUtils

public ObjectUtils()
Method Detail

cloneObject

public static java.lang.Object cloneObject(java.lang.Object obj)
Clones the specified object if it is cloneable and has a public clone() method. Returns the specified instance otherwise.


deepCloneList

public static java.util.List deepCloneList(java.util.List list)
Deep clones a list, iterating and cloning each list element

Parameters:
list -
Returns:
ArrayList

isEquatable

public static boolean isEquatable(java.lang.Object obj)
Returns true if the class of the specified object implements its own .equals() method.


isEquatable

public static boolean isEquatable(java.lang.Class type)
Returns true if the specified class or its hierarchy has its own .equals() method instead of inheriting one from Object.class.


markEquatable

public static void markEquatable(java.lang.Class type)
Manually marks a class as equatable for future checks by the isEquatable method.


markEquatable

public static void markEquatable(java.lang.Object instance)
Manually marks an instance as equatable for future checks by the isEquatable(Object) method.


clearEquatableClasses

public static void clearEquatableClasses()
Clears the list of classes marked as equatable. Primarilly intended for use in tests to reset the static equatable map in between tests.


clearEquatableOverrides

public static void clearEquatableOverrides()
Clears the list of instances marked as equatable. Primarilly intended for use in tests to reset the static overrides set in between tests.


clearEquatables

public static void clearEquatables()
Clears both classes and instances that have been marked as equatable. Primarilly intended for use in tests to reset the static equatable information in between tests.


areEqual

public static boolean areEqual(java.lang.Object o1,
                               java.lang.Object o2)
Returns true if the two objects are equal by reference or by .equals().


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2002-2003 Paul Speed. All Rights Reserved.