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 Entity.protected 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
attributes.field
- 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
Entity.msg
- The CommandMessage
which is being resolved to a
target entity.parent
- The parent
Entity of type T
of this Child Entity.field
- The Field
containing the Child Entity.childEntityModel
- The EntityModel
for the Child
Entity.CommandMessage
.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 based.childEntityModel
- a EntityModel
to retrieve the
routing key properties from.Map
of key/value types String
/
Property
from Command Message name to routing key.protected 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
Entity.message
- The EventMessage
to route.parentEntity
- The parent
Entity of type T
of this Child Entity.field
- The Field
containing the Child Entity.eventForwardingMode
- The ForwardingMode
used to filter the
message
to route based on the ForwardingMode implementation.Stream
of Child Entity targets for the incoming
EventMessage
.Copyright © 2010–2017. All rights reserved.