Class AttributeDefinition.Builder

java.lang.Object
org.mule.runtime.dsl.api.component.AttributeDefinition.Builder
Enclosing class:
AttributeDefinition

public static class AttributeDefinition.Builder extends Object
  • Method Details

    • fromSimpleParameter

      public static AttributeDefinition.Builder fromSimpleParameter(String configParameterName)
      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 public AttributeDefinition.Builder withDefaultValue(Object defaultValue)
      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

      public AttributeDefinition.Builder withWrapperIdentifier(String identifier)
      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

      public static AttributeDefinition.Builder fromFixedValue(Object value)
      Parameters:
      value - a fixed value which will be assigned to the attribute.
      Returns:
      the builder
    • fromFixedReference

      public static AttributeDefinition.Builder fromFixedReference(String reference)
      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

      public static AttributeDefinition.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 a java.util.Map so the attribute type must also be a java.util.Map.

      Returns:
      the builder
    • fromReferenceObject

      public static AttributeDefinition.Builder fromReferenceObject(Class<?> referenceObjectType)
      Used when attribute an attribute must be set with an object provided by the runtime. For instance when the object requires access to the org.mule.runtime.core.api.MuleContext or a org.mule.runtime.core.time.TimeSupplier.
      Parameters:
      referenceObjectType - type of the object expected to be injected.
      Returns:
      the builder
    • fromChildConfiguration

      public static AttributeDefinition.Builder fromChildConfiguration(Class<?> childType)
      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

      public static AttributeDefinition.Builder fromUndefinedComplexAttribute()
      Calling this method declares that the attribute will be assigned with all declared complex configuration object that did not were map by other AttributeDefinitions. By complex attribute we consider those that are represented by complex object types.

      The complex attributes are store in a java.util.List so the attribute type must also be a java.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

      public static AttributeDefinition.Builder fromChildCollectionConfiguration(Class<?> type)
      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

      public static AttributeDefinition.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

      public AttributeDefinition.Builder withIdentifier(String childIdentifier)
    • build

      public AttributeDefinition build()
      Returns:
      the AttributeDefinition created based on the defined configuration.