com.googlecode.ehcache.annotations.key
Class AbstractHashingCacheKeyGenerator<G,T extends java.io.Serializable>

java.lang.Object
  extended by com.googlecode.ehcache.annotations.key.AbstractCacheKeyGenerator<T>
      extended by com.googlecode.ehcache.annotations.key.AbstractDeepCacheKeyGenerator<G,T>
          extended by com.googlecode.ehcache.annotations.key.AbstractHashingCacheKeyGenerator<G,T>
All Implemented Interfaces:
CacheKeyGenerator<T>, ReflectionHelperAware
Direct Known Subclasses:
HashCodeCacheKeyGenerator, MessageDigestCacheKeyGenerator

public abstract class AbstractHashingCacheKeyGenerator<G,T extends java.io.Serializable>
extends AbstractDeepCacheKeyGenerator<G,T>

Common base class for key generators that primarily rely on Object.hashCode(). Has special handling for Class and Enum types as their default hashCode implementations are not portable between JVM instances or versions.

Version:
$Revision: 656 $
Author:
Eric Dalquist

Constructor Summary
AbstractHashingCacheKeyGenerator()
           
AbstractHashingCacheKeyGenerator(boolean includeMethod, boolean includeParameterTypes)
           
 
Method Summary
protected  void append(G generator, java.lang.Object e)
          Append an object to the key.
protected  void appendClass(G generator, java.lang.Class<?> e)
          Uses Class.getName() for the hash code
protected  void appendEnum(G generator, java.lang.Enum<?> e)
          Uses an object array of Object.getClass() and Enum.name() for the hash code
protected abstract  void appendHash(G generator, java.lang.Object e)
           
protected  boolean shouldReflect(java.lang.Object element)
          Default implementation returns true if the Object doesn't implement hashCode or doesn't implement equals.
 
Methods inherited from class com.googlecode.ehcache.annotations.key.AbstractDeepCacheKeyGenerator
append, append, append, append, append, append, append, append, appendGraphCycle, appendNull, beginRecursion, deepHashCode, deepHashCode, deepHashCode, deepHashCode, endRecursion, generateKey, generateKey, getGenerator, getReflectionHelper, isUseReflection, reflectionDeepHashCode, setReflectionHelper, setUseReflection, toString
 
Methods inherited from class com.googlecode.ehcache.annotations.key.AbstractCacheKeyGenerator
generateKey, isCheckforCycles, isIncludeMethod, isIncludeParameterTypes, register, setCheckforCycles, setIncludeMethod, setIncludeParameterTypes, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractHashingCacheKeyGenerator

public AbstractHashingCacheKeyGenerator()

AbstractHashingCacheKeyGenerator

public AbstractHashingCacheKeyGenerator(boolean includeMethod,
                                        boolean includeParameterTypes)
Method Detail

appendClass

protected void appendClass(G generator,
                           java.lang.Class<?> e)
Uses Class.getName() for the hash code


appendEnum

protected void appendEnum(G generator,
                          java.lang.Enum<?> e)
Uses an object array of Object.getClass() and Enum.name() for the hash code


append

protected final void append(G generator,
                            java.lang.Object e)
Description copied from class: AbstractDeepCacheKeyGenerator
Append an object to the key.

Specified by:
append in class AbstractDeepCacheKeyGenerator<G,T extends java.io.Serializable>

shouldReflect

protected boolean shouldReflect(java.lang.Object element)
Description copied from class: AbstractDeepCacheKeyGenerator
Default implementation returns true if the Object doesn't implement hashCode or doesn't implement equals.

Overrides:
shouldReflect in class AbstractDeepCacheKeyGenerator<G,T extends java.io.Serializable>
Parameters:
element - will never be null

appendHash

protected abstract void appendHash(G generator,
                                   java.lang.Object e)


Copyright © 2011. All Rights Reserved.