Interface ContainerModel<T>

Type Parameters:
T - container type

public interface ContainerModel<T>
Low-level model of a container: a collection or a map. Knows how to create an empty container of the same kind, to list its elements, to fill a container with elements and to look up a key; what and how to copy is decided by the caller.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clear(T container)
    Removes all the elements, keeping the configuration of the container.
    boolean
    containsKey(T container, Object key)
    Tells whether the container finds the key (a set element or a map key).
    create(T original)
    Creates an empty container of the same kind as the original: the same class and configuration, e.g.
    elements(T container)
    Lists the elements of the container in iteration order; for a map keys and values in pairs.
    void
    fill(T container, Object[] elements)
    Fills the empty container with the elements, in the order of elements(Object).
    boolean
    Tells whether the container uses hash codes of its keys (set elements or map keys).
    boolean
    Tells whether the container is a map: its elements are keys and values in pairs.
  • Method Details

    • isMap

      boolean isMap()
      Tells whether the container is a map: its elements are keys and values in pairs.
      Returns:
      true for a map
    • hashesKeys

      boolean hashesKeys()
      Tells whether the container uses hash codes of its keys (set elements or map keys). Hash codes of copied keys are final only when the whole object graph is copied.
      Returns:
      true if keys are hashed
    • create

      T create(T original)
      Creates an empty container of the same kind as the original: the same class and configuration, e.g. the key type of an EnumMap.
      Parameters:
      original - original container
      Returns:
      empty container
    • elements

      Object[] elements(T container)
      Lists the elements of the container in iteration order; for a map keys and values in pairs.
      Parameters:
      container - container
      Returns:
      elements
    • fill

      void fill(T container, Object[] elements)
      Fills the empty container with the elements, in the order of elements(Object).
      Parameters:
      container - empty container
      elements - elements
    • containsKey

      boolean containsKey(T container, Object key)
      Tells whether the container finds the key (a set element or a map key).
      Parameters:
      container - container
      key - key
      Returns:
      true if the key is found
    • clear

      void clear(T container)
      Removes all the elements, keeping the configuration of the container.
      Parameters:
      container - container