public final class ClassKey extends java.lang.Object implements java.lang.Comparable<ClassKey>, java.io.Serializable
JsonSerializer
s.
The reason for having a separate key class instead of
directly using Class
as key is mostly
to allow for redefining hashCode
method --
for some strange reason, Class
does not
redefine Object.hashCode()
and thus uses identity
hash, which is pretty slow. This makes key access using
Class
unnecessarily slow.
Note: since class is not strictly immutable, caller must know what it is doing, if changing field values.
Modifier and Type | Field and Description |
---|---|
private java.lang.Class<?> |
_class |
private java.lang.String |
_className |
private int |
_hashCode
Let's cache hash code straight away, since we are
almost certain to need it.
|
private static long |
serialVersionUID |
Constructor and Description |
---|
ClassKey() |
ClassKey(java.lang.Class<?> clz) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ClassKey other) |
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
void |
reset(java.lang.Class<?> clz) |
java.lang.String |
toString() |
private static final long serialVersionUID
private java.lang.String _className
private java.lang.Class<?> _class
private int _hashCode
public void reset(java.lang.Class<?> clz)
public int compareTo(ClassKey other)
compareTo
in interface java.lang.Comparable<ClassKey>
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object