T
- the target type of the inspectorpublic class ModelInspector<T> extends Object implements AggregateModel<T>
T
that creates command and event handlers that delegate to a target entity and
its child entities.Modifier and Type | Method and Description |
---|---|
MessageHandlingMember<? super T> |
commandHandler(String commandName)
Get the
MessageHandlingMember capable of handling commands with given commandName (see CommandMessage.getCommandName() ). |
Map<String,MessageHandlingMember<? super T>> |
commandHandlers()
Get a mapping of
MessageHandlingMember to command name (obtained via CommandMessage.getCommandName() ). |
protected Optional<MessageHandlingMember<? super T>> |
getHandler(Message<?> message)
Returns the
MessageHandlingMember that is capable of handling the given message . |
Object |
getIdentifier(T target)
Get the identifier of the given
target entity. |
Long |
getVersion(T target)
Get the current version number of the given
aggregate . |
static <AT> AggregateModel<AT> |
inspectAggregate(Class<AT> aggregateType)
Create an inspector for given
aggregateType that uses a ClasspathParameterResolverFactory to
resolve method parameters. |
static <T> AggregateModel<T> |
inspectAggregate(Class<T> aggregateType,
ParameterResolverFactory parameterResolverFactory)
Create an inspector for given
aggregateType that uses given parameterResolverFactory to resolve
method parameters. |
<C> ModelInspector<C> |
modelOf(Class<? extends C> entityType)
Get the EntityModel of an entity of type
childEntityType in case it is the child of the modeled entity. |
void |
publish(EventMessage<?> message,
T target)
Publish given event
message on the given target entity. |
String |
routingKey()
Get the name of the routing key property on commands and events that provides the identifier that should be used
to target entities of this kind.
|
String |
type()
Get the String representation of the modeled aggregate's type.
|
public static <AT> AggregateModel<AT> inspectAggregate(Class<AT> aggregateType)
aggregateType
that uses a ClasspathParameterResolverFactory
to
resolve method parameters.AT
- the aggregate's typeaggregateType
- the target aggregate typepublic static <T> AggregateModel<T> inspectAggregate(Class<T> aggregateType, ParameterResolverFactory parameterResolverFactory)
aggregateType
that uses given parameterResolverFactory
to resolve
method parameters.T
- the aggregate's typeaggregateType
- the target aggregate typeparameterResolverFactory
- the resolver factory to use during detectionpublic Map<String,MessageHandlingMember<? super T>> commandHandlers()
EntityModel
MessageHandlingMember
to command name (obtained via CommandMessage.getCommandName()
).commandHandlers
in interface EntityModel<T>
public MessageHandlingMember<? super T> commandHandler(String commandName)
EntityModel
MessageHandlingMember
capable of handling commands with given commandName
(see CommandMessage.getCommandName()
). If the entity is not capable of handling such commands an exception is
raised.commandHandler
in interface EntityModel<T>
commandName
- The name of the commandpublic <C> ModelInspector<C> modelOf(Class<? extends C> entityType)
EntityModel
childEntityType
in case it is the child of the modeled entity.modelOf
in interface EntityModel<T>
C
- the type of the child entityentityType
- The class instance of the child entity typepublic void publish(EventMessage<?> message, T target)
EntityModel
message
on the given target
entity.publish
in interface EntityModel<T>
message
- The event message to publishtarget
- The target entity for the eventpublic String type()
AggregateModel
type
in interface AggregateModel<T>
public Long getVersion(T target)
AggregateModel
aggregate
. For event sourced aggregates this is identical to
the sequence number of the last applied event.getVersion
in interface AggregateModel<T>
target
- The target aggregate root instanceprotected Optional<MessageHandlingMember<? super T>> getHandler(Message<?> message)
MessageHandlingMember
that is capable of handling the given message
. If no member is
found an empty optional is returned.message
- the message to find a handler forpublic Object getIdentifier(T target)
EntityModel
target
entity.getIdentifier
in interface EntityModel<T>
target
- The entity instancepublic String routingKey()
EntityModel
routingKey
in interface EntityModel<T>
Copyright © 2010–2017. All rights reserved.