Class Canonicalizer<T>

  • Type Parameters:
    T - the type of values canonicalized by subclasses

    public class Canonicalizer<T>
    extends Object
    returns canonical representation of objects (similar to String.intern()) to save memory if a.equals(b) then canonicalize(a) == canonicalize(b) this class is thread safe
    • Constructor Detail

      • Canonicalizer

        public Canonicalizer()
    • Method Detail

      • canonicalize

        public final T canonicalize​(T value)
        Parameters:
        value - the value to canonicalize
        Returns:
        the corresponding canonical value
      • toCanonical

        protected T toCanonical​(T value)
        Parameters:
        value - the value to canonicalize if needed
        Returns:
        the canonicalized value