V
- The entry type that will be stored in this registry. This can be anything, really - preferably anything
that works as a HashMap key, as that's what's used to keep track of which entries are registered or not.public class Registry<V> extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
java.util.Collection<V> |
entries
The collection of entries that are currently in this registry.
|
Constructor and Description |
---|
Registry() |
Modifier and Type | Method and Description |
---|---|
java.util.Iterator<V> |
descendingIterator()
Returns an iterator that iterates over each entry in this registry, in the order they were added.
|
java.util.stream.Stream<V> |
descendingStream()
Returns a stream that returns each entry in this registry, in the order they were added.
|
java.util.Iterator<V> |
iterator()
Returns an iterator that iterates over each entry in this registry, with the newest elements iterated over first.
|
boolean |
register(V entry)
Ensures that the entry
entry is registered. |
boolean |
registered(V entry) |
java.util.stream.Stream<V> |
stream()
Returns a stream that contains each entry in this registry, with the newest elements ordered first.
|
void |
unregister(V entry)
Unregisters this entry from this registry.
|
public Registry()
public boolean registered(V entry)
entry
- The entry to check.public boolean register(V entry)
entry
is registered.entry
- The entry to register.public void unregister(V entry)
entry
- The entry to unregister.public java.util.Iterator<V> iterator()
public java.util.Iterator<V> descendingIterator()
forEach
on the entries
collection instead.public java.util.stream.Stream<V> stream()
public java.util.stream.Stream<V> descendingStream()
stream()
method instead.