Class ExtensionModelUtils

java.lang.Object
org.mule.runtime.extension.api.util.ExtensionModelUtils

public class ExtensionModelUtils extends Object
Utility methods for analyzing and decomposing ExtensionModel instances
Since:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    acceptsExpressions(org.mule.runtime.api.meta.ExpressionSupport support)
     
    static boolean
    canBeUsedImplicitly(org.mule.runtime.api.meta.model.parameter.ParameterizedModel parameterizedModel)
    Returns whether the given model can be used implicitly.
    static boolean
    componentHasAnImplicitConfiguration(org.mule.runtime.api.meta.model.ExtensionModel extension, org.mule.runtime.api.meta.model.ComponentModel component)
    Returns whether the given ComponentModel has an associated configuration that can be created implicitly.
    static Set<org.mule.runtime.api.meta.model.config.ConfigurationModel>
    getConfigurationForComponent(org.mule.runtime.api.meta.model.ExtensionModel extensionModel, org.mule.runtime.api.meta.model.ComponentModel component)
     
    static List<org.mule.runtime.api.meta.model.ComponentModel>
    getConnectedComponents(org.mule.runtime.api.meta.model.ExtensionModel extensionModel)
    Returns a List with all the ComponentModel available to the extensionModel which requires a connection.
    static List<org.mule.runtime.api.meta.model.ComponentModel>
    getConnectedComponents(org.mule.runtime.api.meta.model.ExtensionModel extensionModel, org.mule.runtime.api.meta.model.config.ConfigurationModel configurationModel)
    Returns a List with all the ComponentModel available to the configurationModel which requires a connection.
    static Object
    Tests the given object to be annotated with Optional or Optional.
    getDefaultValue(String name, org.mule.metadata.api.model.MetadataType model)
    Retrieves the default value of a field for a given MetadataType
    getDefaultValue(org.mule.runtime.api.meta.model.parameter.ParameterModel model)
     
    static String
    Returns the default value associated with the given annotation.
    static String
    getDefaultValue(org.mule.sdk.api.annotation.param.Optional optional)
    Returns the default value associated with the given annotation.
    getExtensionClassLoader(org.mule.runtime.api.meta.model.ExtensionModel extensionModel)
    Gets the extension ClassLoader
    static <T extends org.mule.runtime.api.meta.model.parameter.ParameterizedModel>
    T
    Returns the first item in the models List that can be used implicitly.
    static Stream<org.mule.runtime.api.util.Pair<org.mule.runtime.api.meta.model.parameter.ParameterGroupModel,org.mule.runtime.api.meta.model.parameter.ParameterModel>>
    getGroupAndParametersPairs(org.mule.runtime.api.meta.model.parameter.ParameterizedModel model)
    Given a ParameterizedModel, it returns a stream with all pairs of groups and parameters involving this model
    static boolean
    hasExpressionDefaultValue(org.mule.runtime.api.meta.model.parameter.ParameterModel model)
     
    static boolean
    isContent(org.mule.runtime.api.meta.model.parameter.ParameterModel parameterModel)
     
    static boolean
    isContent(org.mule.runtime.api.meta.model.parameter.ParameterRole purpose)
     
    static boolean
    isInfrastructure(org.mule.runtime.api.meta.model.parameter.ParameterModel parameter)
     
    static boolean
    isRequired(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel group)
    Tests if the given group contains at least one required ParameterModel
    static boolean
    isRouter(org.mule.runtime.api.meta.model.ComponentModel model)
     
    static boolean
    isRouter(org.mule.runtime.api.meta.model.construct.ConstructModel model)
     
    static boolean
    isScope(org.mule.runtime.api.meta.model.ComponentModel model)
     
    static boolean
    isText(org.mule.runtime.api.meta.model.parameter.ParameterModel parameter)
     
    static boolean
    requiresConfig(org.mule.runtime.api.meta.model.ExtensionModel extensionModel, org.mule.runtime.api.meta.NamedObject component)
     
    static org.mule.runtime.api.meta.model.parameter.ParameterRole
     
    static boolean
    supportsConnectivity(org.mule.runtime.api.meta.model.ExtensionModel extensionModel, org.mule.runtime.api.meta.model.config.ConfigurationModel configurationModel)
     
    static boolean
    supportsMultiple(org.mule.runtime.api.meta.model.nested.NestedRouteModel routeModel)
     
    static org.mule.runtime.api.meta.model.display.ClassValueModel
    Uses the value in the given annotation and transforms it into a ClassValueModel
    static Map<org.mule.metadata.api.model.ObjectType,Set<org.mule.metadata.api.model.ObjectType>>
    toSubTypesMap(Collection<org.mule.runtime.api.meta.model.SubTypesModel> subTypes)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getDefaultValue

      public static Optional<String> getDefaultValue(org.mule.runtime.api.meta.model.parameter.ParameterModel model)
      Parameters:
      model - the parameter who's default value is wanted
      Returns:
      the default value of the parameter
    • hasExpressionDefaultValue

      public static boolean hasExpressionDefaultValue(org.mule.runtime.api.meta.model.parameter.ParameterModel model)
      Parameters:
      model - the parameter who's default value is analyzed
      Returns:
      Whether or not the default value is an expression
      Since:
      1.2
    • getDefaultValue

      public static Optional<String> getDefaultValue(String name, org.mule.metadata.api.model.MetadataType model)
      Retrieves the default value of a field for a given MetadataType
      Parameters:
      name - the field's name
      model - the MetadataType containing the field who's default value is wanted
      Returns:
      the default value of the given parameter
    • acceptsExpressions

      public static boolean acceptsExpressions(org.mule.runtime.api.meta.ExpressionSupport support)
      Parameters:
      support - a ExpressionSupport
      Returns:
      Whether or not the given support is one which accepts or requires expressions
    • getConnectedComponents

      public static List<org.mule.runtime.api.meta.model.ComponentModel> getConnectedComponents(org.mule.runtime.api.meta.model.ExtensionModel extensionModel)
      Returns a List with all the ComponentModel available to the extensionModel which requires a connection. This includes both SourceModel and OperationModel.
      Parameters:
      extensionModel - a ExtensionModel
      Returns:
      a List of ComponentModel. It might be empty but will never be null
    • getConnectedComponents

      public static List<org.mule.runtime.api.meta.model.ComponentModel> getConnectedComponents(org.mule.runtime.api.meta.model.ExtensionModel extensionModel, org.mule.runtime.api.meta.model.config.ConfigurationModel configurationModel)
      Returns a List with all the ComponentModel available to the configurationModel which requires a connection. This includes both SourceModel and OperationModel.
      Parameters:
      extensionModel - the ExtensionModel that owns the configurationModel
      configurationModel - the ConfigurationModel which components you want
      Returns:
      a List of ComponentModel. It might be empty but will never be null
    • supportsConnectivity

      public static boolean supportsConnectivity(org.mule.runtime.api.meta.model.ExtensionModel extensionModel, org.mule.runtime.api.meta.model.config.ConfigurationModel configurationModel)
      Parameters:
      extensionModel - a ExtensionModel
      configurationModel - a ConfigurationModel
      Returns:
      Whether at least one of the models have a ConnectionProviderModel
      Since:
      1.1.4
    • requiresConfig

      public static boolean requiresConfig(org.mule.runtime.api.meta.model.ExtensionModel extensionModel, org.mule.runtime.api.meta.NamedObject component)
      Parameters:
      extensionModel - the model which owns the component
      component - a component
      Returns:
      Whether the given component needs to be provided with a config in order to function
    • getConfigurationForComponent

      public static Set<org.mule.runtime.api.meta.model.config.ConfigurationModel> getConfigurationForComponent(org.mule.runtime.api.meta.model.ExtensionModel extensionModel, org.mule.runtime.api.meta.model.ComponentModel component)
      Parameters:
      extensionModel - the model which owns the component
      component - a component
      Returns:
      A Set with the ConfigurationModel that the can be used alongside with the component
    • isContent

      public static boolean isContent(org.mule.runtime.api.meta.model.parameter.ParameterModel parameterModel)
    • isText

      public static boolean isText(org.mule.runtime.api.meta.model.parameter.ParameterModel parameter)
      Returns:
      true if the given ParameterModel has layout property LayoutModel.isText()
    • isContent

      public static boolean isContent(org.mule.runtime.api.meta.model.parameter.ParameterRole purpose)
    • roleOf

      public static org.mule.runtime.api.meta.model.parameter.ParameterRole roleOf(Optional<Content> content)
    • toSubTypesMap

      public static Map<org.mule.metadata.api.model.ObjectType,Set<org.mule.metadata.api.model.ObjectType>> toSubTypesMap(Collection<org.mule.runtime.api.meta.model.SubTypesModel> subTypes)
    • isInfrastructure

      public static boolean isInfrastructure(org.mule.runtime.api.meta.model.parameter.ParameterModel parameter)
      Returns:
      true if the given ParameterModel was enriched with InfrastructureParameterModelProperty
    • getFirstImplicit

      public static <T extends org.mule.runtime.api.meta.model.parameter.ParameterizedModel> T getFirstImplicit(List<T> models)
      Returns the first item in the models List that can be used implicitly.

      A ParameterizedModel is consider to be implicit when all its ParameterModels are optional

      Type Parameters:
      T - the generic type of the items in the models. It's a type which is assignable from ParameterizedModel
      Parameters:
      models - a List of T
      Returns:
      one of the items in models or null if none of the models are implicit
    • canBeUsedImplicitly

      public static boolean canBeUsedImplicitly(org.mule.runtime.api.meta.model.parameter.ParameterizedModel parameterizedModel)
      Returns whether the given model can be used implicitly. That means that all of its parameters are optional.
      Parameters:
      parameterizedModel - model
      Returns:
      whether the given model can be used implicitly or not.
    • componentHasAnImplicitConfiguration

      public static boolean componentHasAnImplicitConfiguration(org.mule.runtime.api.meta.model.ExtensionModel extension, org.mule.runtime.api.meta.model.ComponentModel component)
      Returns whether the given ComponentModel has an associated configuration that can be created implicitly.
      Parameters:
      extension - the extension where the component belongs
      component - the actual component to check for the implicit config
      Returns:
      true if the component has an implicit associated config, false otherwise.
    • getDefaultValue

      public static String getDefaultValue(Optional optional)
      Returns the default value associated with the given annotation.

      The reason for this method to be instead of simply using Optional.defaultValue() is a limitation on the Java language to have an annotation which defaults to a null value. For that reason, this method tests the default value for equality against the Optional.NULL. If such test is positive, then null is returned.

      If a null optional is supplied, then this method returns null

      Parameters:
      optional - a nullable annotation
      Returns:
      the default value associated to the annotation or null
    • getDefaultValue

      public static String getDefaultValue(org.mule.sdk.api.annotation.param.Optional optional)
      Returns the default value associated with the given annotation.

      The reason for this method to be instead of simply using Optional.defaultValue() is a limitation on the Java language to have an annotation which defaults to a null value. For that reason, this method tests the default value for equality against the Optional.NULL. If such test is positive, then null is returned.

      If a null optional is supplied, then this method returns null

      Parameters:
      optional - a nullable annotation
      Returns:
      the default value associated to the annotation or null
    • getDefaultValue

      public static Object getDefaultValue(AccessibleObject object)
      Tests the given object to be annotated with Optional or Optional.

      If the annotation is present, then a default value is extracted by the rules of getDefaultValue(org.mule.runtime.extension.api.annotation.param.Optional) or getDefaultValue(org.mule.sdk.api.annotation.param.Optional). Otherwise, null is returned.

      Notice that a null return value doesn't necessarily mean that the annotation is not present. It could well be that null happens to be the default value.

      Parameters:
      object - an object potentially annotated with Optional or Optional
      Returns:
      A default value or null
    • isRequired

      public static boolean isRequired(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel group)
      Tests if the given group contains at least one required ParameterModel
      Parameters:
      group - the ParameterGroupModel to be inspected
      Returns:
      true if the given group contains at least one required ParameterModel
    • toClassValueModel

      public static org.mule.runtime.api.meta.model.display.ClassValueModel toClassValueModel(ClassValue annotation)
      Uses the value in the given annotation and transforms it into a ClassValueModel
      Parameters:
      annotation - an annotation
      Returns:
      a ClassValueModel
    • getExtensionClassLoader

      public static Optional<ClassLoader> getExtensionClassLoader(org.mule.runtime.api.meta.model.ExtensionModel extensionModel)
      Gets the extension ClassLoader
      Parameters:
      extensionModel -
      Returns:
      an Optional with the extension ClassLoader
    • getGroupAndParametersPairs

      public static Stream<org.mule.runtime.api.util.Pair<org.mule.runtime.api.meta.model.parameter.ParameterGroupModel,org.mule.runtime.api.meta.model.parameter.ParameterModel>> getGroupAndParametersPairs(org.mule.runtime.api.meta.model.parameter.ParameterizedModel model)
      Given a ParameterizedModel, it returns a stream with all pairs of groups and parameters involving this model
      Parameters:
      model -
      Returns:
      a Stream of Pair of ParameterGroupModel and its ParameterModel, associated to the model.
    • isScope

      public static boolean isScope(org.mule.runtime.api.meta.model.ComponentModel model)
      Parameters:
      model - a ComponentModel
      Returns:
      Whether the given model represents a Scope
      Since:
      1.5.0
    • isRouter

      public static boolean isRouter(org.mule.runtime.api.meta.model.construct.ConstructModel model)
      Parameters:
      model - a ConstructModel
      Returns:
      Whether the given model represents a Router
      Since:
      1.5.0
    • isRouter

      public static boolean isRouter(org.mule.runtime.api.meta.model.ComponentModel model)
      Parameters:
      model - a ComponentModel
      Returns:
      Whether the given model represents a Router
      Since:
      1.7.0
    • supportsMultiple

      public static boolean supportsMultiple(org.mule.runtime.api.meta.model.nested.NestedRouteModel routeModel)