public abstract class AbstractChildEntityDefinition extends Object implements ChildEntityDefinition
ChildEntityDefinition
to provide reusable functionality for collections of
ChildEntityDefinitions.Constructor and Description |
---|
AbstractChildEntityDefinition() |
Modifier and Type | Method and Description |
---|---|
<T> Optional<ChildEntity<T>> |
createChildDefinition(Field field,
EntityModel<T> declaringEntity)
Inspect the given
field , which is declared on the given declaringEntity for the presence of a
Child Entity. |
protected abstract <T> EntityModel<Object> |
extractChildEntityModel(EntityModel<T> declaringEntity,
Map<String,Object> attributes,
Field field)
Extracts the Child Entity contained in the given
declaringEntity as an EntityModel . |
protected Map<String,Property<Object>> |
extractCommandHandlerRoutingKeys(Field field,
EntityModel<Object> childEntityModel)
Retrieves the routing keys of every command handler on the given
childEntityModel to be able to correctly
route commands to Entities. |
protected abstract boolean |
isFieldTypeSupported(Field field)
Check whether the given
Field is of a type supported by this definition. |
protected abstract <T> Object |
resolveCommandTarget(CommandMessage<?> msg,
T parent,
Field field,
EntityModel<Object> childEntityModel)
Resolve the target of an incoming
CommandMessage to the right Child
Entity. |
protected abstract <T> Stream<Object> |
resolveEventTargets(EventMessage message,
T parentEntity,
Field field,
ForwardingMode eventForwardingMode)
Resolve the targets of an incoming
EventMessage to the right Child
Entities. |
public <T> Optional<ChildEntity<T>> createChildDefinition(Field field, EntityModel<T> declaringEntity)
ChildEntityDefinition
field
, which is declared on the given declaringEntity
for the presence of a
Child Entity.createChildDefinition
in interface ChildEntityDefinition
T
- The type of entity on which the field is declaredfield
- The field potentially containing a Child entitydeclaringEntity
- The entity model declaring the fieldprotected abstract boolean isFieldTypeSupported(Field field)
Field
is of a type supported by this definition.field
- a Field
containing a Child Entityprotected abstract <T> EntityModel<Object> extractChildEntityModel(EntityModel<T> declaringEntity, Map<String,Object> attributes, Field field)
declaringEntity
as an EntityModel
.
The type of the Child Entity is defined through a key in the provided attributes
or based on given
Field
.T
- the type T
of the given declaringEntity
EntityModel
declaringEntity
- the EntityModel
declaring the given field
attributes
- a Map
containing the AggregateMember
attributesfield
- the Field
containing the Child Entity.declaringEntity
protected abstract <T> Object resolveCommandTarget(CommandMessage<?> msg, T parent, Field field, EntityModel<Object> childEntityModel)
CommandMessage
to the right Child
Entity. Returns the Child Entity the msg
needs to be routed to.T
- the type T
of the given parent
Entitymsg
- the CommandMessage
which is being resolved to a
target entityparent
- the parent
Entity of type T
of this Child Entityfield
- the Field
containing the Child Entity.childEntityModel
- the EntityModel
for the Child EntityCommandMessage
.protected Map<String,Property<Object>> extractCommandHandlerRoutingKeys(Field field, EntityModel<Object> childEntityModel)
childEntityModel
to be able to correctly
route commands to Entities.field
- a Field
denoting the Child Entity upon which the
childEntityModel
is basedchildEntityModel
- a EntityModel
to retrieve the routing key properties fromMap
of key/value types String
Property
from Command Message name to routing keyprotected abstract <T> Stream<Object> resolveEventTargets(EventMessage message, T parentEntity, Field field, ForwardingMode eventForwardingMode)
EventMessage
to the right Child
Entities. Returns a Stream
of all the Child Entities the Event Message should be
routed to.T
- the type T
of the given parent
Entitymessage
- the EventMessage
to routeparentEntity
- the parent
Entity of type T
of this Child Entityfield
- the Field
containing the Child EntityeventForwardingMode
- the ForwardingMode
used to filter the message
to route based on the
ForwardingMode implementationStream
of Child Entity targets for the incoming
EventMessage
Copyright © 2010–2020. All rights reserved.