dk.cloudcreate.essentials.components.eventsourced.aggregates.decider.AggregateIdResolver 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;
import java.util.Optional;
/**
* Interface responsible for resolve the optional aggregate id associated with the type T
* Example of usages:
*
* - Command - return the aggregate id associated with the command (can return an {@link Optional#empty()})
* in case server generated id's are used for commands that create a new Aggregate instance)
* - Event - return the aggregate id associated with the event
* - State - return the aggregate id associated with the aggregate state event projection
* - View - return the aggregate id associated with the View event projection
*
*
* @param The type of object that this resolver support. Could e.g. be a COMMAND
, EVENT
, Aggregate STATE
, VIEW
, etc.
* @param The type of Aggregate Id
*/
public interface AggregateIdResolver {
/**
* Resolve the optional aggregate id associated with the type T
* Example of usages:
*
* - Command - return the aggregate id associated with the command (can return an {@link Optional#empty()})
* in case server generated id's are used for commands that create a new Aggregate instance)
* - Event - return the aggregate id associated with the event
* - State - return the aggregate id associated with the aggregate state event projection
* - View - return the aggregate id associated with the View event projection
*
*
* @param t the instance of T
* @return if the t
contains an aggregate id then it MUST be returned
* in an {@link Optional#of(Object)} otherwise an {@link Optional#empty()}
*/
Optional resolveFrom(T t);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy