Class ReferenceEqualityKey<K>

  • Type Parameters:
    K - the key type

    public class ReferenceEqualityKey<K>
    extends java.lang.Object
    An object for wrapping a HashMap key so that the hashmap performs reference equality on the keys, not equals() equality.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private K wrappedKey
      The wrapped key.
    • Constructor Summary

      Constructors 
      Constructor Description
      ReferenceEqualityKey​(K wrappedKey)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      Equals.
      K get()
      Get the wrapped key.
      int hashCode()
      Hash code.
      java.lang.String toString()
      To string.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • wrappedKey

        private final K wrappedKey
        The wrapped key.
    • Constructor Detail

      • ReferenceEqualityKey

        public ReferenceEqualityKey​(K wrappedKey)
        Constructor.
        Parameters:
        wrappedKey - the wrapped key
    • Method Detail

      • get

        public K get()
        Get the wrapped key.
        Returns:
        the wrapped key.
      • hashCode

        public int hashCode()
        Hash code.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the int
      • equals

        public boolean equals​(java.lang.Object obj)
        Equals.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the obj
        Returns:
        true, if successful
      • toString

        public java.lang.String toString()
        To string.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the string