Class Registry<T>

  • Type Parameters:
    T - The type of the registered objects

    public class Registry<T>
    extends java.lang.Object
    A registry of identifiable objects.
    Since:
    0.5.0
    • Constructor Summary

      Constructors 
      Constructor Description
      Registry()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T byId​(java.lang.String id)
      Gets the value of the given identifier.
      java.util.Set<java.util.Map.Entry<java.lang.String,​T>> entries()
      Gets an immutable-view of all entries (key + value) registered into the registry.
      void forEach​(java.util.function.BiConsumer<java.lang.String,​T> consumer)  
      java.util.Set<java.lang.String> keys()
      Gets an immutable-view of value keys registered into the registry.
      Registry<T> register​(java.lang.String id, T value)
      Registers the given value, with the given identifier.
      java.util.Collection<T> values()
      Gets an immutable-view of all values registered into the registry.
      • Methods inherited from class java.lang.Object

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

      • Registry

        public Registry()
    • Method Detail

      • register

        public Registry<T> register​(java.lang.String id,
                                    T value)
        Registers the given value, with the given identifier.
        Parameters:
        id - The identifier of the value
        value - The value
        Returns:
        this, for chaining
      • byId

        public T byId​(java.lang.String id)
        Gets the value of the given identifier.
        Parameters:
        id - The identifier of the value
        Returns:
        The value, or null if not present
      • keys

        public java.util.Set<java.lang.String> keys()
        Gets an immutable-view of value keys registered into the registry.
        Returns:
        The keys
        Since:
        0.5.3
        See Also:
        Map.keySet()
      • values

        public java.util.Collection<T> values()
        Gets an immutable-view of all values registered into the registry.
        Returns:
        The values
        See Also:
        Map.values()
      • entries

        public java.util.Set<java.util.Map.Entry<java.lang.String,​T>> entries()
        Gets an immutable-view of all entries (key + value) registered into the registry.
        Returns:
        The entries
        Since:
        0.5.3
        See Also:
        Map.entrySet()
      • forEach

        public void forEach​(java.util.function.BiConsumer<java.lang.String,​T> consumer)
        Parameters:
        consumer - The action to be performed for each entry
        See Also:
        Map.forEach(BiConsumer)