equals and hashCode methods follow the
the rules laid out in Effective Java by Joshua Bloch.
To generate a KeyFactory, you need to supply an interface which
describes the structure of the key. The interface should have a
single method named newInstance, which returns an
Object. The arguments array can be
anything--Objects, primitive values, or single or
multi-dimension arrays of either. For example:
private interface IntStringKey {
public Object newInstance(int i, String s);
}
Once you have made a KeyFactory, you generate a new key by calling
the newInstance method defined by your interface.
IntStringKey factory = (IntStringKey)KeyFactory.create(IntStringKey.class);
Object key1 = factory.newInstance(4, "Hello");
Object key2 = factory.newInstance(4, "World");
Note
hashCode equality between two keys key1 and key2 is only guaranteed if
key1.equals(key2) and the keys were produced by the same factory.
| Modifier and Type | Class and Description |
|---|---|
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final Signature | |
| public static final Customizer | |
| private static final Signature | |
| private static final Signature | |
| private static final Signature | |
| private static final Signature | |
| public static final HashCodeCustomizer | HASH_ASM_TYPE
|
| private static final Signature | |
| private static final Type | |
| public static final Customizer | OBJECT_BY_CLASS
Deprecated
this customizer might result in unexpected class leak since key object still holds a strong reference to the Object and class.
It is recommended to have pre-processing method that would strip Objects and represent Classes as Strings
|
| private static final int[] | |
| public static final FieldTypeCustomizer | |
| private static final Signature |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static KeyFactory | |
| public static KeyFactory | |
| public static KeyFactory | |
| public static KeyFactory | |
| public static KeyFactory | create(ClassLoader loader, Class<T> keyInterface, KeyFactoryCustomizer customizer, List<KeyFactoryCustomizer> next)
|
| APPEND_STRING | back to summary |
|---|---|
| private static final Signature APPEND_STRING | |
| CLASS_BY_NAME | back to summary |
|---|---|
| public static final Customizer CLASS_BY_NAME | |
| EQUALS | back to summary |
|---|---|
| private static final Signature EQUALS | |
| GET_CLASS | back to summary |
|---|---|
| private static final Signature GET_CLASS | |
| GET_NAME | back to summary |
|---|---|
| private static final Signature GET_NAME | |
| GET_SORT | back to summary |
|---|---|
| private static final Signature GET_SORT | |
| HASH_ASM_TYPE | back to summary |
|---|---|
| public static final HashCodeCustomizer HASH_ASM_TYPE
| |
| HASH_CODE | back to summary |
|---|---|
| private static final Signature HASH_CODE | |
| KEY_FACTORY | back to summary |
|---|---|
| private static final Type KEY_FACTORY | |
| OBJECT_BY_CLASS | back to summary |
|---|---|
| public static final Customizer OBJECT_BY_CLASS
Deprecated this customizer might result in unexpected class leak since key object still holds a strong reference to the Object and class. It is recommended to have pre-processing method that would strip Objects and represent Classes as Strings | |
| PRIMES | back to summary |
|---|---|
| private static final int[] PRIMES | |
| STORE_CLASS_AS_STRING | back to summary |
|---|---|
| public static final FieldTypeCustomizer STORE_CLASS_AS_STRING | |
| TO_STRING | back to summary |
|---|---|
| private static final Signature TO_STRING | |
| KeyFactory | back to summary |
|---|---|
| protected KeyFactory() | |
| create | back to summary |
|---|---|
| public static KeyFactory create(Class<T> keyInterface) | |
| create | back to summary |
|---|---|
| public static KeyFactory create(Class<T> keyInterface, Customizer customizer) | |
| create | back to summary |
|---|---|
| public static KeyFactory create(Class<T> keyInterface, KeyFactoryCustomizer first, List<KeyFactoryCustomizer> next) | |
| create | back to summary |
|---|---|
| public static KeyFactory create(ClassLoader loader, Class<T> keyInterface, Customizer customizer) | |
| create | back to summary |
|---|---|
| public static KeyFactory create(ClassLoader loader, Class<T> keyInterface, KeyFactoryCustomizer customizer, List<KeyFactoryCustomizer> next) | |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private CustomizerRegistry | |
| private Class | |
| private static final Class | |
| private int | |
| private static final AbstractClassGenerator. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public KeyFactory | |
| protected Object | firstInstance(Class<T> type)
Implements abstract org.
|
| public void | |
| public <T> List | |
| protected ClassLoader | |
| private String | |
| protected ProtectionDomain | getProtectionDomain()
Overrides org. Returns the protection domain to use when defining the class. |
| protected Object | nextInstance(Object instance)
Implements abstract org.
|
| public void | |
| public void | |
| public void | |
| public void |
| constant | back to summary |
|---|---|
| private int constant | |
| customizers | back to summary |
|---|---|
| private CustomizerRegistry customizers | |
| keyInterface | back to summary |
|---|---|
| private Class<T> keyInterface | |
| KNOWN_CUSTOMIZER_TYPES | back to summary |
|---|---|
| private static final Class<T>[] KNOWN_CUSTOMIZER_TYPES | |
| multiplier | back to summary |
|---|---|
| private int multiplier | |
| SOURCE | back to summary |
|---|---|
| private static final AbstractClassGenerator. | |
| Generator | back to summary |
|---|---|
| public Generator() | |
| addCustomizer | back to summary |
|---|---|
| public void addCustomizer(KeyFactoryCustomizer customizer) | |
| create | back to summary |
|---|---|
| public KeyFactory create() | |
| firstInstance | back to summary |
|---|---|
| protected Object firstInstance(Class<T> type) Implements abstract org.
| |
| generateClass | back to summary |
|---|---|
| public void generateClass(ClassVisitor v) Implements org.
| |
| getCustomizers | back to summary |
|---|---|
| public <T> List | |
| getDefaultClassLoader | back to summary |
|---|---|
| protected ClassLoader getDefaultClassLoader() Implements abstract org.
| |
| getFieldName | back to summary |
|---|---|
| private String getFieldName(int arg) | |
| getProtectionDomain | back to summary |
|---|---|
| protected ProtectionDomain getProtectionDomain() Overrides org. Doc from org. Returns the protection domain to use when defining the class.
Default implementation returns
| |
| nextInstance | back to summary |
|---|---|
| protected Object nextInstance(Object instance) Implements abstract org.
| |
| setCustomizer | back to summary |
|---|---|
| public void setCustomizer(Customizer customizer)
Deprecated Use
| |
| setHashConstant | back to summary |
|---|---|
| public void setHashConstant(int constant) | |
| setHashMultiplier | back to summary |
|---|---|
| public void setHashMultiplier(int multiplier) | |
| setInterface | back to summary |
|---|---|
| public void setInterface(Class<T> keyInterface) | |