T - the type of a Kubernetes resource@ThreadSafe public class EventQueue<T extends HasMetadata> extends AbstractCollection<AbstractEvent<T>>
AbstractCollection of AbstractEvents produced by an EventQueueCollection.
All AbstractEvents in an EventQueue describe the
life of a single resource in
Kubernetes.
This class is safe for concurrent use by multiple Threads. Some operations, like the usage of the iterator() method, require that callers synchronize on the EventQueue directly. This class' internals synchronize on this when locking is needed.
Overrides of this class must also be safe for concurrent use by
multiple Threads.
EventQueueCollection| Modifier and Type | Field and Description |
|---|---|
protected Logger |
logger
A
Logger for use by this EventQueue. |
| Modifier | Constructor and Description |
|---|---|
protected |
EventQueue(Object key)
Creates a new
EventQueue. |
| Modifier and Type | Method and Description |
|---|---|
protected Collection<AbstractEvent<T>> |
compress(Collection<AbstractEvent<T>> events)
Performs a compression operation on the supplied
Collection of AbstractEvents and returns the result of that
operation. |
protected Logger |
createLogger()
Returns a
Logger for use by this EventQueue. |
boolean |
equals(Object other)
|
void |
forEach(Consumer<? super AbstractEvent<T>> action)
Synchronizes on this
EventQueue and, while holding its
monitor, invokes the Consumer.accept(Object) method on
the supplied Consumer for every AbstractEvent in
this EventQueue. |
Object |
getKey()
Returns the key identifying the Kubernetes resource to which all
of the
AbstractEvents managed by this EventQueue
apply. |
int |
hashCode()
Returns a hashcode for this
EventQueue. |
boolean |
isEmpty()
Returns
true if this EventQueue is empty. |
Iterator<AbstractEvent<T>> |
iterator()
Synchronizes on this
EventQueue and, while holding its
monitor, returns an unmodifiable Iterator over its
contents. |
int |
size()
Returns the size of this
EventQueue. |
String |
toString()
Returns a
String representation of this EventQueue. |
add, addAll, clear, contains, containsAll, remove, removeAll, retainAll, toArray, toArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitparallelStream, removeIf, spliterator, streamprotected final Logger logger
createLogger()protected EventQueue(Object key)
EventQueue.key - the key identifying the Kubernetes resource to which
all of the AbstractEvents managed by this EventQueue apply; must not be nullNullPointerException - if key is nullIllegalStateException - if the createLogger()
method returns nullprotected Logger createLogger()
Logger for use by this EventQueue.
This method never returns null.
Overrides of this method must not return null.
null Loggerpublic final Object getKey()
AbstractEvents managed by this EventQueue
apply.
This method never returns null.
null ObjectEventQueue(Object)public final boolean isEmpty()
true if this EventQueue is empty.isEmpty in interface Collection<AbstractEvent<T extends HasMetadata>>isEmpty in class AbstractCollection<AbstractEvent<T extends HasMetadata>>true if this EventQueue is empty; false otherwisesize()public final int size()
EventQueue.
This method never returns an int less than 0.
size in interface Collection<AbstractEvent<T extends HasMetadata>>size in class AbstractCollection<AbstractEvent<T extends HasMetadata>>EventQueue; never negativeisEmpty()public final void forEach(Consumer<? super AbstractEvent<T>> action)
EventQueue and, while holding its
monitor, invokes the Consumer.accept(Object) method on
the supplied Consumer for every AbstractEvent in
this EventQueue.action - the Consumer in question; must not be
nullNullPointerException - if action is nullpublic final Iterator<AbstractEvent<T>> iterator()
EventQueue and, while holding its
monitor, returns an unmodifiable Iterator over its
contents.
This method never returns null.
iterator in interface Iterable<AbstractEvent<T extends HasMetadata>>iterator in interface Collection<AbstractEvent<T extends HasMetadata>>iterator in class AbstractCollection<AbstractEvent<T extends HasMetadata>>null unmodifiable Iterator of
AbstractEventsprotected Collection<AbstractEvent<T>> compress(Collection<AbstractEvent<T>> events)
Collection of AbstractEvents and returns the result of that
operation.
This method may return null, which will result in the
emptying of this EventQueue.
This method is called while holding this EventQueue's
monitor.
This method is called when an EventQueueCollection (or
some other AbstractEvent producer with access to
package-protected methods of this class) adds an AbstractEvent to
this EventQueue and provides the EventQueue
implementation with the ability to eliminate duplicates or
otherwise compress the event stream it represents.
This implementation simply returns the supplied events
Collection; i.e. no compression is performed.
events - an unmodifiable
Collection of AbstractEvents representing the
current state of this EventQueue; will never be nullEventQueue should assume;
may be null; may simply be the supplied events
Collection if compression is not desired or implementedpublic final int hashCode()
EventQueue.hashCode in interface Collection<AbstractEvent<T extends HasMetadata>>hashCode in class ObjectEventQueueequals(Object)public final boolean equals(Object other)
equals in interface Collection<AbstractEvent<T extends HasMetadata>>equals in class Objectother - the Object to test; may be null in
which case null will be returnedtrue if the supplied Object is also an
EventQueue and is equal in all respects to this one;
false otherwisehashCode()public final String toString()
toString in class AbstractCollection<AbstractEvent<T extends HasMetadata>>null String representation of this
EventQueueCopyright © 2017–2021, microBean™. All rights reserved.