Class 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>
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 Summary
ConstructorsConstructorDescriptionFieldChildEntityFieldDefinition(Class<P> parentClass, String fieldName) Creates a newChildEntityFieldDefinitionthat uses the given field to access the child entity. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.evolveParentBasedOnChildInput(P parentEntity, F childInput) Evolves the parent entity based on the provided child value.getChildValue(P parentEntity) Returns the type of the field.
-
Constructor Details
-
FieldChildEntityFieldDefinition
Creates a newChildEntityFieldDefinitionthat 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
Description copied from interface:ChildEntityFieldDefinitionEvolves 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:
evolveParentBasedOnChildInputin interfaceChildEntityFieldDefinition<P,F> - Parameters:
parentEntity- The parent entity to evolve.childInput- The child entity to use for evolution.- Returns:
- The evolved parent entity.
-
getChildValue
Description copied from interface:ChildEntityFieldDefinitionReturns the type of the field.- Specified by:
getChildValuein interfaceChildEntityFieldDefinition<P,F> - Parameters:
parentEntity- The parent entity to get the child entities from.- Returns:
- The type of the field.
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods 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
DescribableComponentimplementation 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 thedescribeTomethod, 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:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-