Class FieldChildEntityFieldDefinition<P,F>

java.lang.Object
org.axonframework.modelling.entity.child.FieldChildEntityFieldDefinition<P,F>
Type Parameters:
P - The type of the parent entity.
F - The type of the field. This can be the type of the child entity or a collection of child entities.
All Implemented Interfaces:
DescribableComponent, ChildEntityFieldDefinition<P,F>

public class FieldChildEntityFieldDefinition<P,F> extends Object implements ChildEntityFieldDefinition<P,F>, DescribableComponent
A ChildEntityFieldDefinition that uses a field to access the child entity. If getters or setters are available, it will use those instead.
Since:
5.0.0
Author:
Mitchell Herrijgers
  • Constructor Details

    • FieldChildEntityFieldDefinition

      public FieldChildEntityFieldDefinition(@Nonnull Class<P> parentClass, @Nonnull String fieldName)
      Creates a new ChildEntityFieldDefinition that uses the given field to access the child entity.
      Parameters:
      parentClass - The class of the parent entity.
      fieldName - The name of the field to use to access the child entity.
  • Method Details

    • evolveParentBasedOnChildInput

      @Nonnull public P evolveParentBasedOnChildInput(@Nonnull P parentEntity, @Nonnull F childInput)
      Description copied from interface: ChildEntityFieldDefinition
      Evolves the parent entity based on the provided child value. This can be a single entity, or a collection of entities. The evolver can return a new version of the parent entity, or it can simply set the field on the parent entity.
      Specified by:
      evolveParentBasedOnChildInput in interface ChildEntityFieldDefinition<P,F>
      Parameters:
      parentEntity - The parent entity to evolve.
      childInput - The child entity to use for evolution.
      Returns:
      The evolved parent entity.
    • getChildValue

      public F getChildValue(@Nonnull P parentEntity)
      Description copied from interface: ChildEntityFieldDefinition
      Returns the type of the field.
      Specified by:
      getChildValue in interface ChildEntityFieldDefinition<P,F>
      Parameters:
      parentEntity - The parent entity to get the child entities from.
      Returns:
      The type of the field.
    • describeTo

      public void describeTo(@Nonnull ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.

      Best Practices: As a general rule, all relevant fields of a DescribableComponent implementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing the describeTo method, who should focus on providing information that is useful for understanding the component's configuration and state.

      Example implementation:

       public void describeTo(ComponentDescriptor descriptor) {
           descriptor.describeProperty("name", this.name);
           descriptor.describeProperty("enabled", this.enabled);
           descriptor.describeProperty("configuration", this.configuration); // A nested component
           descriptor.describeProperty("handlers", this.eventHandlers);      // A collection
       }
       
      Specified by:
      describeTo in interface DescribableComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.