@ParametersAreNonnullByDefault public interface JohnsonEventContainer
Events
Johnson maintains exactly one event container, which is accessed statically. As a result, all implementations of this interface are required to be thread-safe. However, because Johnson may be used to filter all requests to the application, implementations should be careful in how they achieve that thread-safety. Using heavy synchronisation techniques may impose significant performance penalties.
| Modifier and Type | Method and Description |
|---|---|
void |
addEvent(Event event)
Adds the provided event to the collection.
|
Optional<Event> |
firstEvent(Predicate<? super Event> predicate)
Returns the first event (if any) that satisfies the given predicate.
|
Collection<Event> |
getEvents()
Retrieves an immutable view of the contained
Events. |
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
Events in the container. |
void |
removeEvent(Event event)
Removes the specified
Event from the container, if it can be found. |
void addEvent(Event event)
event - the event to add@Nonnull Collection<Event> getEvents()
Events.boolean hasEvents()
Events in the container.
This can be thought of as a shortcut for !getEvents().isEmpty().
true if there are events; otherwise, falsevoid removeEvent(Event event)
Event from the container, if it can be found.
Warning: Due to how Event.equals(Object) and Event.hashCode() are implemented, an exact
match on every field is required in order to match an event. As a result, it may be necessary to iterate over
the events in the collection and remove the event using the exact instance already in the
collection.
event - the event to removeCollection<Event> getEvents(Predicate<? super Event> predicate)
predicate - the predicate to evaluateboolean hasEvent(Predicate<? super Event> predicate)
firstEvent(Predicate) followed by
Optional.isPresent().predicate - the predicate to evaluatefalseif no events matchOptional<Event> firstEvent(Predicate<? super Event> predicate)
predicate - the predicate to evaluategetEvents()Copyright © 2017 Atlassian. All rights reserved.