public class TimestampedCollection<K,V> extends Object
| Modifier and Type | Method and Description |
|---|---|
long |
getOldestRegistrationTimestamp()
Returns a timestamp of the oldest registered subject.
|
boolean |
isEmpty()
Call this function to determine whether the collection is empty or not.
|
static <K,V> TimestampedCollection<K,V> |
newInstance() |
V |
register(K correlationId,
V subject)
Registers a
subject and maps it to a given correlationId. |
boolean |
register(long timestamp,
V subject)
Creates a new
subject registration. |
boolean |
register(V subject)
Creates a new
subject registration. |
V |
remove(K correlationId)
Removes a registration from the collection based on a
correlationId and returns
the value of the registered subject. |
List<V> |
removeAll()
Removes all values from the time-stamped collection and returns them as an ordered FIFO
list.
|
V |
removeOldest()
Removes the oldest registration from the collection and returns the value of
the registered
subject. |
int |
size()
Returns the number of elements in this collection.
|
public static <K,V> TimestampedCollection<K,V> newInstance()
public V register(@NotNull K correlationId, @NotNull V subject)
subject and maps it to a given correlationId.
The newly created registration is timestamped which allows for later removal
based on the age of registration using removeOldest() method.correlationId - correlation identifier to be associated with a given subjectsubject - a primary registration objectsubject associated with a given correlationId
or null if there's no such subjectremove(java.lang.Object),
removeOldest()public boolean register(@NotNull
V subject)
subject registration. The newly created registration
is timestamped which allows for later removal based on the age of registration
using removeOldest() method.subject - a primary registration subjecttrue if the registration was successfull, false otherwiseremoveOldest()public boolean register(long timestamp,
@NotNull
V subject)
subject registration. The newly created registration
is timestamped using a value of the timestamp parameter which allows
for later removal based on the age of registration using removeOldest()
method.timestamp - a timestamp to be used for the registrationsubject - a primary registration subjecttrue if the registration was successfull, false otherwiseremoveOldest()public V remove(@NotNull K correlationId)
correlationId and returns
the value of the registered subject. This method may return nullcorrelationId - identifier to be associated with an already registered subjectsubject associated with a given correlationId
or null if there's no such subjectregister(java.lang.Object, java.lang.Object)public V removeOldest()
subject.subjectNoSuchElementException - if the underlying collection is empty.register(java.lang.Object, java.lang.Object),
register(java.lang.Object),
register(long, java.lang.Object)public List<V> removeAll()
public boolean isEmpty()
true if the collection is empty, false otherwisepublic int size()
Integer.MAX_VALUE elements, returns
Integer.MAX_VALUE.public long getOldestRegistrationTimestamp()
NoSuchElementException - if the underlying collection is empty.removeOldest()Copyright © 2005–2018 Oracle Corporation. All rights reserved.