jpaul.Misc
Class IdentityWrapper<T>

java.lang.Object
  extended by jpaul.Misc.IdentityWrapper<T>

public class IdentityWrapper<T>
extends java.lang.Object

IdentityWrapper is useful when you want to assign some information to each object, not to each class of equal objects. An IdentityWrapper is a wrapper around the original object that redefines equals and hashCode to implement "equality as identity".

Version:
$Id: IdentityWrapper.java,v 1.3 2006/03/14 02:29:31 salcianu Exp $
Author:
Alexandru Salcianu - salcianu@alum.mit.edu

Field Summary
 T obj
           
 
Constructor Summary
IdentityWrapper(T obj)
          Creates a IdentityWrapper.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

obj

public final T obj
Constructor Detail

IdentityWrapper

public IdentityWrapper(T obj)
Creates a IdentityWrapper.

Parameters:
obj - Object to wrap.
Method Detail

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright 2005 Alexandru Salcianu - salcianu@alum.mit.edu