Module org.mule.runtime.dsl.api
Class AttributeDefinition.Builder
java.lang.Object
org.mule.runtime.dsl.api.component.AttributeDefinition.Builder
- Enclosing class:
- AttributeDefinition
-
Method Summary
Modifier and TypeMethodDescriptionbuild()static AttributeDefinition.BuilderfromChildCollectionConfiguration(Class<?> type) Used when an attribute must be set with a collection of objects created from the user configuration.static AttributeDefinition.BuilderfromChildConfiguration(Class<?> childType) Used when an attribute must be set with a complex object created from the user configuration.static AttributeDefinition.BuilderfromChildMapConfiguration(Class<?> keyType, Class<?> valueType) Used when an attribute must be set with a map of objects created from the user configuration.static AttributeDefinition.BuilderfromFixedReference(String reference) Use when the reference is fixed (and not configurable), not the value.static AttributeDefinition.BuilderfromFixedValue(Object value) static AttributeDefinition.BuilderfromMultipleDefinitions(KeyAttributeDefinitionPair... definitions) Used when several attributes or child components needs to be mapped to a single attribute.static AttributeDefinition.BuilderfromReferenceObject(Class<?> referenceObjectType) Used when attribute an attribute must be set with an object provided by the runtime.static AttributeDefinition.BuilderfromSimpleParameter(String configParameterName) static AttributeDefinition.BuilderfromSimpleParameter(String configParameterName, TypeConverter typeConverter) static AttributeDefinition.BuilderfromSimpleReferenceParameter(String referenceSimpleParameter) static AttributeDefinition.BuilderfromSimpleReferenceParameter(String configParameterName, TypeConverter typeConverter) static AttributeDefinition.BuilderfromSoftReferenceSimpleParameter(String softReferenceParameter) static AttributeDefinition.BuilderUsed when an attribute must be created with the inner content of the configuration element.static AttributeDefinition.BuilderCalling this method declares that the attribute will be assigned with all declared complex configuration object that did not were map by otherAttributeDefinitions.static AttributeDefinition.BuilderCalling this method declares that the attribute will be assigned with all declared simple configuration attribute and its value.withDefaultValue(Object defaultValue) Deprecated.obtain the default values from the AST/extension model instead.withIdentifier(String childIdentifier) withWrapperIdentifier(String identifier) Defines the parent identifier used to wrap a child element.
-
Method Details
-
fromSimpleParameter
- Parameters:
configParameterName- name of the configuration parameter from which this attribute value will be extracted.- Returns:
- the builder
-
fromSimpleParameter
public static AttributeDefinition.Builder fromSimpleParameter(String configParameterName, TypeConverter typeConverter) - Parameters:
configParameterName- name of the configuration parameter from which this attribute value will be extracted.typeConverter- converter from the configuration value to a custom type.- Returns:
- the builder
-
fromSimpleReferenceParameter
public static AttributeDefinition.Builder fromSimpleReferenceParameter(String configParameterName, TypeConverter typeConverter) - Parameters:
configParameterName- name of the configuration parameter from which this attribute value will be extracted.typeConverter- converter from the configuration value to a custom type.- Returns:
- the builder
-
withDefaultValue
Deprecated.obtain the default values from the AST/extension model instead.- Parameters:
defaultValue- defines the default value to be used for the attribute if no other value is provided.- Returns:
- the builder
-
withWrapperIdentifier
Defines the parent identifier used to wrap a child element. Useful when there are children with the same type and we need to make a distinction to know how to do injection over multiple attributes with the same type. The identifier provided does not require a component definition since it will be just for qualifying a child. i.e.:<parent-component> <first-wrapper> <child-component> </first-wrapper> <second-wrapper> <child-component> </second-wrapper> </parent-component>The first-wrapper and second-wrapper elements are just used to univocally identify the object attribute in which the child-component object must be injected.- Parameters:
identifier- component identifier in the configuration for the parent element wrapping the child component- Returns:
-
fromFixedValue
- Parameters:
value- a fixed value which will be assigned to the attribute.- Returns:
- the builder
-
fromFixedReference
Use when the reference is fixed (and not configurable), not the value.- Parameters:
reference- a fixed reference object which will be assigned to the attribute.- Returns:
- the builder
-
fromUndefinedSimpleAttributes
Calling this method declares that the attribute will be assigned with all declared simple configuration attribute and its value. By simple attribute we consider those with a key and a string value as content. The simple attributes are store in ajava.util.Mapso the attribute type must also be ajava.util.Map.- Returns:
- the builder
-
fromReferenceObject
Used when attribute an attribute must be set with an object provided by the runtime. For instance when the object requires access to theorg.mule.runtime.core.api.MuleContextor aorg.mule.runtime.core.time.TimeSupplier.- Parameters:
referenceObjectType- type of the object expected to be injected.- Returns:
- the builder
-
fromChildConfiguration
Used when an attribute must be set with a complex object created from the user configuration.- Parameters:
childType- type of the required complex object.- Returns:
- the builder
-
fromUndefinedComplexAttribute
Calling this method declares that the attribute will be assigned with all declared complex configuration object that did not were map by otherAttributeDefinitions. By complex attribute we consider those that are represented by complex object types. The complex attributes are store in ajava.util.Listso the attribute type must also be ajava.util.List.- Returns:
- the builder
-
fromSimpleReferenceParameter
public static AttributeDefinition.Builder fromSimpleReferenceParameter(String referenceSimpleParameter) - Parameters:
referenceSimpleParameter- configuration attribute that holds a reference to another configuration object.- Returns:
- the builder
-
fromSoftReferenceSimpleParameter
public static AttributeDefinition.Builder fromSoftReferenceSimpleParameter(String softReferenceParameter) -
fromChildCollectionConfiguration
Used when an attribute must be set with a collection of objects created from the user configuration.- Parameters:
type- the collection object type.- Returns:
- the builder
-
fromChildMapConfiguration
public static AttributeDefinition.Builder fromChildMapConfiguration(Class<?> keyType, Class<?> valueType) Used when an attribute must be set with a map of objects created from the user configuration.- Parameters:
keyType- the map key type.valueType- the map value type.- Returns:
- the builder
-
fromTextContent
Used when an attribute must be created with the inner content of the configuration element.- Returns:
- the builder
-
fromMultipleDefinitions
public static AttributeDefinition.Builder fromMultipleDefinitions(KeyAttributeDefinitionPair... definitions) Used when several attributes or child components needs to be mapped to a single attribute. The attribute must be of type Map where the key are the attribute name or the child element name and the value is the actual object.- Parameters:
definitions- the set of attribute definitions along with its keys- Returns:
- the builder
-
withIdentifier
-
build
- Returns:
- the
AttributeDefinitioncreated based on the defined configuration.
-