Class JXCSkinCache<T>

java.lang.Object
com.realtime.crossfire.jxclient.skin.skin.JXCSkinCache<T>
Type Parameters:
T - the type of the cached elements
All Implemented Interfaces:
Iterable<T>

public class JXCSkinCache<T> extends Object implements Iterable<T>
Implements a cache for elements identified by name.
  • Constructor Details

    • JXCSkinCache

      public JXCSkinCache(@NotNull @NotNull String ident)
      Creates a new instance.
      Parameters:
      ident - the description of this cache used for creating error messages
  • Method Details

    • clear

      public void clear()
      Forgets all cached elements.
    • insert

      public void insert(@NotNull @NotNull String name, @NotNull T t) throws JXCSkinException
      Adds a new element to the cache.
      Parameters:
      name - the element name to add
      t - the element to add
      Throws:
      JXCSkinException - if the element name is not unique
    • lookup

      @NotNull public T lookup(@NotNull @NotNull String name) throws JXCSkinException
      Looks up an element by name.
      Parameters:
      name - the name of the element
      Returns:
      the element
      Throws:
      JXCSkinException - if no such element exists
    • getNames

      @NotNull public @NotNull Collection<String> getNames()
      Returns all defined names.
      Returns:
      the names in alphabetical order
    • lookupOptional

      @Nullable public T lookupOptional(@NotNull @NotNull String name)
      Looks up an element by name.
      Parameters:
      name - the name of the element
      Returns:
      the element or null if no such element exists
    • iterator

      @NotNull public @NotNull Iterator<T> iterator()
      Returns all stored values.
      Specified by:
      iterator in interface Iterable<T>
      Returns:
      an (read-only) iterator returning all stored values