Package org.cadixdev.lorenz.util
Class Registry<T>
- java.lang.Object
-
- org.cadixdev.lorenz.util.Registry<T>
-
- Type Parameters:
T- The type of the registered objects
public class Registry<T> extends java.lang.ObjectA 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 TbyId(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.voidforEach(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.
-
-
-
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 valuevalue- 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
nullif 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)
-
-