dk.cloudcreate.essentials.components.eventsourced.aggregates.decider.Handler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eventsourced-aggregates Show documentation
Show all versions of eventsourced-aggregates Show documentation
This library focuses on providing different flavors of eventsourced aggregrates
/*
* Copyright 2021-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dk.cloudcreate.essentials.components.eventsourced.aggregates.decider;
/**
* {@link Decider} related interface that is responsible for handling COMMAND
(s),whose side effect is either an ERROR
or a List of EVENT
's (can be an empty list)
*
* @param The type of Commands that the {@link #handle(Object, Object)} can process
* @param The type of Events that can be returned by {@link #handle(Object, Object)} and applied in the {@link StateEvolver#applyEvent(Object, Object)}
* @param The type of Error that can be returned by the {@link #handle(Object, Object)} method
* @param The type of Aggregate State that this {@link Decider} works with in {@link #handle(Object, Object)}, {@link InitialStateProvider#initialState()}, {@link StateEvolver#applyEvent(Object, Object)}
* and {@link IsStateFinalResolver#isFinal(Object)}
*/
@FunctionalInterface
public interface Handler {
/**
* The execute
method is responsible for handling a COMMAND
, which can either result
* in an ERROR
or a list of EVENT
's (can be an empty list).
* Note: This method is called decide
in the decider pattern
* Idempotent handling of a COMMAND
will result in an empty list of EVENT
's
*
* @param cmd the command to handle
* @param state the state of the aggregate
* @return either an ERROR
or a list of EVENT
's.
* Idempotent handling of a COMMAND
will result in an empty list of EVENT
's
*/
HandlerResult handle(COMMAND cmd, STATE state);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy