public class ExtensionModelUtils extends Object
ExtensionModel
instancesModifier and Type | Method and Description |
---|---|
static boolean |
acceptsExpressions(ExpressionSupport support) |
static boolean |
canBeUsedImplicitly(ParameterizedModel parameterizedModel)
Returns whether the given model can be used implicitly.
|
static boolean |
componentHasAnImplicitConfiguration(ExtensionModel extension,
ComponentModel component)
Returns whether the given
ComponentModel has an associated configuration that can be created implicitly. |
static Set<ConfigurationModel> |
getConfigurationForComponent(ExtensionModel extensionModel,
ComponentModel component) |
static List<ComponentModel> |
getConnectedComponents(ExtensionModel extensionModel)
Returns a
List with all the ComponentModel available to the extensionModel which requires a
connection. |
static List<ComponentModel> |
getConnectedComponents(ExtensionModel extensionModel,
ConfigurationModel configurationModel)
Returns a
List with all the ComponentModel available to the configurationModel which requires a
connection. |
static Object |
getDefaultValue(AccessibleObject object)
Tests the given
object to be annotated with Optional . |
static String |
getDefaultValue(Optional optional)
Returns the default value associated with the given annotation.
|
static Optional<String> |
getDefaultValue(ParameterModel model) |
static Optional<String> |
getDefaultValue(String name,
MetadataType model)
Retrieves the default value of a field for a given
MetadataType |
static <T extends ParameterizedModel> |
getFirstImplicit(List<T> models)
Returns the first item in the
models List that can be used implicitly. |
static boolean |
isContent(ParameterModel parameterModel) |
static boolean |
isContent(ParameterRole purpose) |
static boolean |
isInfrastructure(ParameterModel parameter) |
static boolean |
isRequired(ParameterGroupModel group)
Tests if the given
group contains at least one required ParameterModel |
static boolean |
isText(ParameterModel parameter) |
static boolean |
requiresConfig(ExtensionModel extensionModel,
NamedObject component) |
static ParameterRole |
roleOf(Optional<Content> content) |
static ClassValueModel |
toClassValueModel(ClassValue annotation)
Uses the value in the given
annotation and transforms it into a ClassValueModel |
static Map<ObjectType,Set<ObjectType>> |
toSubTypesMap(Collection<SubTypesModel> subTypes) |
public static Optional<String> getDefaultValue(ParameterModel model)
model
- the parameter
who's default value is wantedpublic static Optional<String> getDefaultValue(String name, MetadataType model)
MetadataType
name
- the field's namemodel
- the MetadataType
containing the field who's default value is wantedpublic static boolean acceptsExpressions(ExpressionSupport support)
support
- a ExpressionSupport
support
is one which accepts or requires expressionspublic static List<ComponentModel> getConnectedComponents(ExtensionModel extensionModel)
List
with all the ComponentModel
available to the extensionModel
which requires a
connection. This includes both SourceModel
and OperationModel
.extensionModel
- a ExtensionModel
List
of ComponentModel
. It might be empty but will never be null
public static List<ComponentModel> getConnectedComponents(ExtensionModel extensionModel, ConfigurationModel configurationModel)
List
with all the ComponentModel
available to the configurationModel
which requires a
connection. This includes both SourceModel
and OperationModel
.extensionModel
- the ExtensionModel
that owns the configurationModel
configurationModel
- the ConfigurationModel
which components you wantList
of ComponentModel
. It might be empty but will never be null
public static boolean requiresConfig(ExtensionModel extensionModel, NamedObject component)
extensionModel
- the model which owns the component
component
- a componentcomponent
needs to be provided with a config
in order to functionpublic static Set<ConfigurationModel> getConfigurationForComponent(ExtensionModel extensionModel, ComponentModel component)
extensionModel
- the model which owns the component
component
- a componentSet
with the ConfigurationModel
that the can be used alongside with the component
public static boolean isContent(ParameterModel parameterModel)
public static boolean isText(ParameterModel parameter)
true
if the given ParameterModel
has layout property
LayoutModel.isText()
public static boolean isContent(ParameterRole purpose)
public static ParameterRole roleOf(Optional<Content> content)
public static Map<ObjectType,Set<ObjectType>> toSubTypesMap(Collection<SubTypesModel> subTypes)
public static boolean isInfrastructure(ParameterModel parameter)
true
if the given ParameterModel
was enriched with InfrastructureParameterModelProperty
public static <T extends ParameterizedModel> T getFirstImplicit(List<T> models)
models
List
that can be used implicitly.
A ParameterizedModel
is consider to be implicit when all its ParameterModel
s are optional
T
- the generic type of the items in the models
. It's a type which is assignable from
ParameterizedModel
models
- a List
of T
models
or null
if none of the models are implicitpublic static boolean canBeUsedImplicitly(ParameterizedModel parameterizedModel)
parameterizedModel
- modelpublic static boolean componentHasAnImplicitConfiguration(ExtensionModel extension, ComponentModel component)
ComponentModel
has an associated configuration that can be created implicitly.extension
- the extension where the component belongscomponent
- the actual component to check for the implicit configpublic static String getDefaultValue(Optional optional)
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
optional
- a nullable annotationnull
public static Object getDefaultValue(AccessibleObject object)
object
to be annotated with 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)
. 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.
object
- an object potentially annotated with Optional
null
public static boolean isRequired(ParameterGroupModel group)
group
contains at least one required ParameterModel
group
- the ParameterGroupModel
to be inspectedtrue
if the given group
contains at least one required ParameterModel
public static ClassValueModel toClassValueModel(ClassValue annotation)
annotation
and transforms it into a ClassValueModel
annotation
- an annotationClassValueModel
Copyright © 2018. All rights reserved.