Class SelectableNamedStorage<T extends IName>

Type Parameters:
T - The type of the objects that are stored in this storage.
All Implemented Interfaces:
IName

public abstract class SelectableNamedStorage<T extends IName> extends NamedStorage<T> implements IName
Implementation of a named selectable storage. This storage is used to store objects that implement the IName interface. It also has a current object that can be set and retrieved. The current object is used for example to get the default object.
  • Constructor Details

    • SelectableNamedStorage

      public SelectableNamedStorage()
      Creates a new named storage with a CopyOnWriteArrayList.
    • SelectableNamedStorage

      public SelectableNamedStorage(Supplier<List<T>> list)
      Creates a new named storage with the given list.
      Parameters:
      list - The list.
  • Method Details

    • getDefault

      public abstract T getDefault()
      Gets the default object. This is the object that is returned when getCurrent() is called and the current object is null.
      Returns:
      The default object.
    • getCurrent

      public T getCurrent()
      Gets the current object. If the current object is null, the default object is returned.
      Returns:
      The current object.
    • setCurrent

      public void setCurrent(T current)
    • setCurrentByName

      public void setCurrentByName(String name)
      Sets the current object by its name.
      Parameters:
      name - The name.