Package com.aoindustries.collections
Class IdentityKey<T>
- java.lang.Object
-
- com.aoindustries.collections.IdentityKey<T>
-
public class IdentityKey<T> extends Object
Allows any object to be used as a hash key, with identity used forhashCode()
andequals(java.lang.Object)
. They may be used, for example, to haveIdentityHashMap
semantics withWeakHashMap
references.Supports
null
value, which may allownull
keys in maps that otherwise do not supportnull
keys.- Author:
- AO Industries, Inc.
-
-
Field Summary
Fields Modifier and Type Field Description static IdentityKey<?>
NULL
-
Constructor Summary
Constructors Constructor Description IdentityKey(T value)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
T
getValue()
int
hashCode()
static <T> IdentityKey<T>
of(T value)
Gets the identity key for the given value orNULL
for anull
value.static <T> IdentityKey<T>
ofNull()
Gets the identity key that representsnull
.String
toString()
-
-
-
Field Detail
-
NULL
public static final IdentityKey<?> NULL
-
-
Constructor Detail
-
IdentityKey
@Deprecated public IdentityKey(T value)
Deprecated.
-
-
Method Detail
-
ofNull
public static <T> IdentityKey<T> ofNull()
Gets the identity key that representsnull
.
-
of
public static <T> IdentityKey<T> of(T value)
Gets the identity key for the given value orNULL
for anull
value.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classObject
- See Also:
System.identityHashCode(java.lang.Object)
-
getValue
public T getValue()
-
-