Class IdentityMap<K,​E extends Entity<K>>

java.lang.Object
de.calamanari.pk.identitymap.IdentityMap<K,​E>
Type Parameters:
K - type of the entity key
E - entity type

public class IdentityMap<K,​E extends Entity<K>>
extends java.lang.Object
Identity Map - demonstrates IDENTITY MAP
Author:
Karl Eilebrecht
  • Constructor Summary

    Constructors
    Constructor Description
    IdentityMap​(java.lang.Class<E> entityType)
    Creates identity map
  • Method Summary

    Modifier and Type Method Description
    void add​(E entity)
    Adds an entity to the map
    E get​(K id)
    Returns the requested entity corresponding to the key
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • IdentityMap

      public IdentityMap​(java.lang.Class<E> entityType)
      Creates identity map
      Parameters:
      entityType - class of entity to be maintained
  • Method Details

    • add

      public void add​(E entity)
      Adds an entity to the map
      Parameters:
      entity - (null will be silently ignored)
    • get

      public E get​(K id)
      Returns the requested entity corresponding to the key
      Parameters:
      id - (primary key)
      Returns:
      entity or null if unknown
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object