Class Interners.InternerImpl<E>

  • All Implemented Interfaces:
    Interner<E>
    Enclosing class:
    Interners

    static final class Interners.InternerImpl<E>
    extends java.lang.Object
    implements Interner<E>
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private InternerImpl​(MapMaker mapMaker)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      E intern​(E sample)
      Chooses and returns the representative instance for any of a collection of instances that are equal to each other.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InternerImpl

        private InternerImpl​(MapMaker mapMaker)
    • Method Detail

      • intern

        public E intern​(E sample)
        Description copied from interface: Interner
        Chooses and returns the representative instance for any of a collection of instances that are equal to each other. If two equal inputs are given to this method, both calls will return the same instance. That is, intern(a).equals(a) always holds, and intern(a) == intern(b) if and only if a.equals(b). Note that intern(a) is permitted to return one instance now and a different instance later if the original interned instance was garbage-collected.

        Warning: do not use with mutable objects.

        Specified by:
        intern in interface Interner<E>