/** * Returns a stream of events that should be recorded. By default, an empty stream returned. * * @return stream of events * @throws Exception if the command is to be rejected, an exception has to be thrown. In this case, no events will * be recorded */ public EventStream<S> events() throws Exception { return EventStream.empty(); }
/** * Returns a stream of events that should be recorded. By default, calls {@link #events()} * * @param repository Configured repository * @return stream of events * @throws Exception if the command is to be rejected, an exception has to be thrown. In this case, no events will * be recorded */ public EventStream<S> events(Repository repository) throws Exception { return events(); }
@Override public UUID getValue(EntityHandle<T> object, QueryOptions queryOptions) { return object.uuid(); } };
@Override public HybridTimestamp result(UUID state, Repository repository) { return repository.getJournal().get(state).get().timestamp(); } }
public LocalLockProviderTest() { super(new LocalLockProvider()); } }
/** * By default, calls {@link #result(Object)} * * @param state * @param repository * @return result */ public R result(S state, Repository repository) { return result(state); }
/** * EventStream builder * * @param state state * @param <S> state type * @return */ public static <S> Builder<S> builder(S state) { return new Builder<>(state); }
/** * @param state state * @param stream stream of events * @param <S> state type * @return event stream with a state and a stream */ public static <S> EventStream<S> ofWithState(S state, Stream<? extends Event> stream) { return new EventStream<>(state, stream); }
@Override public CloseableIterator<EntityHandle<T>> iterator(QueryOptions queryOptions) { return journal.eventIterator(klass, queryOptions); } }
/** * Defines a predicate for matching entities * @param repository * @param entity * @return true if the entity should be returned */ default boolean matches(Repository repository, T entity) { return matches(entity); }
/** * Used by {@link #accept(Stream)} to be invoked for every entity handle. * Does nothing by default. * @param repository * @param entity */ default void onEntity(Repository repository, EntityHandle<T> entity) { onEntity(entity); }
@Override public Set<Class<? extends Command>> getCommands() { return scan(Command.class); } }
@Override public Set<Class<? extends Event>> getEvents() { return scan(Event.class); } }
@Override public CloseableIterator<EntityHandle<T>> iterator(QueryOptions queryOptions) { return journal.commandIterator(klass, queryOptions); } }
@Override public HybridTimestamp result(UUID state, Repository repository) { return repository.getJournal().get(state).get().timestamp(); } }
/** * By default, it calls {@link #result()} * * @param state * @return result */ public R result(S state) { return result(); }
/** * EventStream builder with state set to <code>null</code> * * @param <S> state type * @return */ public static <S> Builder<S> builder() { return new Builder<>(null); }
/** * @param stream stream of events * @param <S> state type * @return event stream with a state set to <code>null</code> and a stream */ public static <S> EventStream<S> of(Stream<? extends Event> stream) { return new EventStream<>(null, stream); }