@ParametersAreNonnullByDefault public class DefaultJohnsonEventContainer extends Object implements JohnsonEventContainer
JohnsonEventContainer which stores events in a list.
Note: This implementation is thread-safe.
| Constructor and Description |
|---|
DefaultJohnsonEventContainer() |
| Modifier and Type | Method and Description |
|---|---|
void |
addEvent(Event event)
Adds the provided
Event to the list. |
void |
clear()
Removes all events from this container.
|
Optional<Event> |
firstEvent(Predicate<? super Event> predicate)
Returns the first event (if any) that satisfies the given predicate.
|
List<Event> |
getEvents()
Retrieves an unmodifiable view of the current
Event list. |
Collection<Event> |
getEvents(Predicate<? super Event> predicate)
Returns any events that satisfy the given predicate.
|
boolean |
hasEvent(Predicate<? super Event> predicate)
Indicates whether this container has any events that satisfy the given predicate.
|
boolean |
hasEvents()
Retrieves a flag indicating whether there are any
Events in the list. |
void |
removeEvent(Event event)
Removes the provided
Event from the list, if it can be found. |
Stream<Event> |
stream()
Retrieves a stream which can be used to filter, map, sort or otherwise iterate over the
events
in the container. |
public void addEvent(Event event)
Event to the list.addEvent in interface JohnsonEventContainerevent - the event to addpublic void clear()
JohnsonEventContainerclear in interface JohnsonEventContainer@Nonnull public Optional<Event> firstEvent(Predicate<? super Event> predicate)
JohnsonEventContainerfirstEvent in interface JohnsonEventContainerpredicate - the predicate to evaluateJohnsonEventContainer.getEvents()@Nonnull public List<Event> getEvents()
Event list.getEvents in interface JohnsonEventContainer@Nonnull public Collection<Event> getEvents(Predicate<? super Event> predicate)
JohnsonEventContainergetEvents in interface JohnsonEventContainerpredicate - the predicate to evaluatepublic boolean hasEvent(Predicate<? super Event> predicate)
JohnsonEventContainerJohnsonEventContainer.firstEvent(Predicate) followed by
Optional.isPresent().hasEvent in interface JohnsonEventContainerpredicate - the predicate to evaluatefalseif no events matchpublic boolean hasEvents()
Events in the list.hasEvents in interface JohnsonEventContainertrue if the event list is not empty; otherwise, falsepublic void removeEvent(Event event)
Event from the list, if it can be found.removeEvent in interface JohnsonEventContainerevent - the event to remove@Nonnull public Stream<Event> stream()
JohnsonEventContainerevents
in the container.stream in interface JohnsonEventContainerStream over the events in the containerCopyright © 2018 Atlassian. All rights reserved.