Search in sources :

Example 1 with TypedValueValueResolverWrapper

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;
}
Also used : TypedValueValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.TypedValueValueResolverWrapper) StackedTypesModelProperty.getStackedTypesModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.stackabletypes.StackedTypesModelProperty.getStackedTypesModelProperty) StackedTypesModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.stackabletypes.StackedTypesModelProperty) ParameterResolverValueResolverWrapper(org.mule.runtime.module.extension.internal.runtime.resolver.ParameterResolverValueResolverWrapper) ExpressionBasedParameterResolverValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionBasedParameterResolverValueResolver) StaticValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver) ExpressionTypedValueValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionTypedValueValueResolver) NativeQueryParameterValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.NativeQueryParameterValueResolver) ValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver) ProcessorChainValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ProcessorChainValueResolver) TypeSafeExpressionValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.TypeSafeExpressionValueResolver) StaticLiteralValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticLiteralValueResolver) StaticLiteralValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticLiteralValueResolver) StaticValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver)

Aggregations

StackedTypesModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.stackabletypes.StackedTypesModelProperty)1 StackedTypesModelProperty.getStackedTypesModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.stackabletypes.StackedTypesModelProperty.getStackedTypesModelProperty)1 ExpressionBasedParameterResolverValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionBasedParameterResolverValueResolver)1 ExpressionTypedValueValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.ExpressionTypedValueValueResolver)1 NativeQueryParameterValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.NativeQueryParameterValueResolver)1 ParameterResolverValueResolverWrapper (org.mule.runtime.module.extension.internal.runtime.resolver.ParameterResolverValueResolverWrapper)1 ProcessorChainValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.ProcessorChainValueResolver)1 StaticLiteralValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.StaticLiteralValueResolver)1 StaticValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver)1 TypeSafeExpressionValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.TypeSafeExpressionValueResolver)1 TypedValueValueResolverWrapper (org.mule.runtime.module.extension.internal.runtime.resolver.TypedValueValueResolverWrapper)1 ValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver)1