T
- the type of a Kubernetes resource@ThreadSafe public class EventQueue<T extends HasMetadata> extends AbstractCollection<AbstractEvent<T>>
AbstractCollection
of AbstractEvent
s produced by an EventQueueCollection
.
All AbstractEvent
s in an EventQueue
describe the
life of a single resource in
Kubernetes.
This class is safe for concurrent use by multiple Thread
s. 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 Thread
s.
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 AbstractEvent s 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
AbstractEvent s 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, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
parallelStream, removeIf, spliterator, stream
protected final Logger logger
createLogger()
protected EventQueue(Object key)
EventQueue
.key
- the key identifying the Kubernetes resource to which
all of the AbstractEvent
s managed by this EventQueue
apply; must not be null
NullPointerException
- if key
is null
IllegalStateException
- if the createLogger()
method returns null
protected Logger createLogger()
Logger
for use by this EventQueue
.
This method never returns null
.
Overrides of this method must not return null
.
null
Logger
public final Object getKey()
AbstractEvent
s managed by this EventQueue
apply.
This method never returns null
.
null
Object
EventQueue(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
null
NullPointerException
- if action
is null
public 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
AbstractEvent
sprotected Collection<AbstractEvent<T>> compress(Collection<AbstractEvent<T>> events)
Collection
of AbstractEvent
s 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 AbstractEvent
s representing the
current state of this EventQueue
; will never be null
EventQueue
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 Object
EventQueue
equals(Object)
public final boolean equals(Object other)
equals
in interface Collection<AbstractEvent<T extends HasMetadata>>
equals
in class Object
other
- 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
EventQueue
Copyright © 2017–2021, microBean™. All rights reserved.