use of org.mule.runtime.module.extension.internal.runtime.resolver.TypedValueValueResolverWrapper in project mule by mulesoft.
the class ExtensionDefinitionParser method getStaticValueResolver.
/**
* Generates the {@link ValueResolver} for non expression based values
*/
private ValueResolver getStaticValueResolver(String parameterName, MetadataType expectedType, Object value, Object defaultValue, Set<ModelProperty> modelProperties, boolean acceptsReferences, Class<?> expectedClass) {
Optional<StackedTypesModelProperty> optionalStackedTypeModelProperty = getStackedTypesModelProperty(modelProperties);
if (optionalStackedTypeModelProperty.isPresent()) {
StackedTypesModelProperty property = optionalStackedTypeModelProperty.get();
Optional<ValueResolver> optionalResolver = property.getValueResolverFactory().getStaticValueResolver(value, Literal.class);
if (optionalResolver.isPresent()) {
return optionalResolver.get();
}
}
if (isLiteral(expectedType)) {
return new StaticLiteralValueResolver<>(value != null ? value.toString() : null, expectedClass);
}
ValueResolver resolver;
resolver = value != null ? getValueResolverFromMetadataType(parameterName, expectedType, value, defaultValue, acceptsReferences, expectedClass) : new StaticValueResolver<>(defaultValue);
if (optionalStackedTypeModelProperty.isPresent()) {
resolver = optionalStackedTypeModelProperty.get().getValueResolverFactory().getWrapperValueResolver(resolver);
} else if (isParameterResolver(expectedType)) {
resolver = new ParameterResolverValueResolverWrapper(resolver);
} else if (isTypedValue(expectedType)) {
resolver = new TypedValueValueResolverWrapper(resolver);
}
return resolver;
}
Aggregations