Class OrderedRegistry<T>
java.lang.Object
net.buildtheearth.terraminusminus.util.OrderedRegistry<T>
A sort of "registry", in which entries are identified by a
String key.
Entries maintain a strict order, and can be inserted/removed at either end of the registry, or at positions relative to each other.
Not thread-safe.
Inspired by Netty's ChannelPipeline.
Will probably be hoisted into PorkLib at some point.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a new entry immediately before the entry with the given name.Adds a new entry immediately before the entry with the given name.Adds a new entry at the beginning of the registry.Adds a new entry at the end of the registry.protected voidassertUniqueName(@NonNull String name) Removes the existing entry with the given name.Removes the existing entry with the given name.Replaces the existing entry with the given name.Replaces the existing entry with the given name.toString()
-
Field Details
-
list
-
-
Constructor Details
-
OrderedRegistry
public OrderedRegistry()
-
-
Method Details
-
addFirst
Adds a new entry at the beginning of the registry.- Parameters:
name- the namevalue- the value
-
addLast
Adds a new entry at the end of the registry.- Parameters:
name- the namevalue- the value
-
addBefore
public OrderedRegistry<T> addBefore(@NonNull @NonNull String targetName, @NonNull @NonNull String name, @NonNull T value) Adds a new entry immediately before the entry with the given name.- Parameters:
targetName- the name of the entry that the new entry should be inserted beforename- the namevalue- the value
-
addAfter
public OrderedRegistry<T> addAfter(@NonNull @NonNull String targetName, @NonNull @NonNull String name, @NonNull T value) Adds a new entry immediately before the entry with the given name.- Parameters:
targetName- the name of the entry that the new entry should be inserted beforename- the namevalue- the value
-
set
Replaces the existing entry with the given name.- Parameters:
targetName- the name of the entry that the new entry should be inserted beforevalue- the value
-
set
public OrderedRegistry<T> set(@NonNull @NonNull String targetName, @NonNull @NonNull String newName, @NonNull T value) Replaces the existing entry with the given name.- Parameters:
targetName- the name of the entry that the new entry should be inserted beforenewName- the namevalue- the value
-
remove
Removes the existing entry with the given name.- Parameters:
name- the name of the entry to remove
-
get
Removes the existing entry with the given name.- Parameters:
name- the name of the entry to remove
-
assertUniqueName
-
entryStream
- Returns:
- a
Streamover all the entries in this registry
-
toString
-