@SPI
@FunctionalInterface
public interface EventFilter
Event
s posted by a Repository
.
A filter may allow any event, reject certain types of events, or change the event content.
FunctionalInterface
, so that an event filter may be
defined with a lambda expression.Modifier and Type | Method and Description |
---|---|
static EventFilter |
allowAll()
Obtains an
EventFilter which always returns the input event without any change. |
default com.google.common.collect.ImmutableCollection<io.spine.core.Event> |
filter(java.util.Collection<io.spine.core.Event> events)
Applies this filter to the given
Event s in bulk. |
java.util.Optional<? extends io.spine.base.EventMessage> |
filter(io.spine.base.EventMessage event)
Applies this filter to the given event.
|
static EventFilter allowAll()
EventFilter
which always returns the input event without any change.
The method acts as if
static EventFilter allowAll() {
return Optional::of;
}
java.util.Optional<? extends io.spine.base.EventMessage> filter(io.spine.base.EventMessage event)
event
- the event to apply the filter toOptional.empty()
if the event should not be posteddefault com.google.common.collect.ImmutableCollection<io.spine.core.Event> filter(java.util.Collection<io.spine.core.Event> events)
Event
s in bulk.events
- the events to apply the filter to