org.metasyntactic.core
Class Equals

java.lang.Object
  |
  +--org.metasyntactic.core.Equals

public class Equals
extends java.lang.Object

Convenience class to test the equality of two objects (either of which can be null). Often times java programmers must write the same snippet of code over and over again:


	return this == null ? that == null : this.equals(that);
 

An alternative (at almost no cost whatsoever) is to just type:

 return Equals.equals(this, that);
 

To get the same effect.


Method Summary
static boolean equals(java.lang.Object o1, java.lang.Object o2)
          If o1 is null, this method returns true if o2 is null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

equals

public static final boolean equals(java.lang.Object o1,
                                   java.lang.Object o2)
If o1 is null, this method returns true if o2 is null. If o1 is not null this method returns the result of o1.equals(o2).

Note! This method should have no overhead over the alternative:


	return this == null ? that == null : this.equals(that);
 

because it has been declared final and thus will be collapsed into any method calling it

Parameters:
o1 - The first object
o2 - The second object
Returns:
true if boeth objects are null. Or if the first object is not null, if o1.equals(o2) returns true