Search in sources :

Example 6 with DefaultObjectBuilder

use of org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder in project mule by mulesoft.

the class DefaultObjectBuilderTestCase method buildInterface.

@Test(expected = IllegalArgumentException.class)
public void buildInterface() throws Exception {
    builder = new DefaultObjectBuilder(InternalMessage.class);
    builder.build(resolvingContext);
}
Also used : InternalMessage(org.mule.runtime.core.internal.message.InternalMessage) DefaultObjectBuilder(org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 7 with DefaultObjectBuilder

use of org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder in project mule by mulesoft.

the class TopLevelParameterObjectFactory method injectFields.

private void injectFields() {
    DefaultObjectBuilder builder = this.builder.get();
    builder.setEncoding(muleContext.getConfiguration().getDefaultEncoding());
    if (name != null) {
        builder.setName(name);
    }
}
Also used : DefaultObjectBuilder(org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder)

Example 8 with DefaultObjectBuilder

use of org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder in project mule by mulesoft.

the class ComponentMessageProcessor method createFieldParameterGroupBuilder.

private ObjectBuilder createFieldParameterGroupBuilder(ParameterGroupDescriptor groupDescriptor, List<ParameterModel> fieldParameters) {
    DefaultObjectBuilder groupBuilder = new DefaultObjectBuilder(groupDescriptor.getType().getDeclaringClass().get());
    fieldParameters.forEach(p -> {
        ValueResolver resolver = resolverSet.getResolvers().get(p.getName());
        if (resolver != null) {
            groupBuilder.addPropertyResolver(getMemberName(p), resolver);
        }
    });
    return groupBuilder;
}
Also used : ParameterValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ParameterValueResolver) ValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ValueResolver) DefaultObjectBuilder(org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder)

Example 9 with DefaultObjectBuilder

use of org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder in project mule by mulesoft.

the class ParametersResolver method resolveParameterGroups.

/**
 * {@inheritDoc}
 */
@Override
public void resolveParameterGroups(ObjectType objectType, DefaultObjectBuilder builder) {
    Class<?> objectClass = getType(objectType);
    objectType.getFields().stream().filter(ExtensionMetadataTypeUtils::isFlattenedParameterGroup).forEach(groupField -> {
        if (!(groupField.getValue() instanceof ObjectType)) {
            return;
        }
        final ObjectType groupType = (ObjectType) groupField.getValue();
        final Field objectField = getField(objectClass, getLocalPart(groupField));
        DefaultObjectBuilder groupBuilder = getParameterGroupObjectBuilder(groupField);
        builder.addPropertyResolver(objectField.getName(), new ObjectBuilderValueResolver<>(groupBuilder, muleContext));
        resolveParameters(groupType, groupBuilder);
        resolveParameterGroups(groupType, groupBuilder);
    });
}
Also used : ObjectType(org.mule.metadata.api.model.ObjectType) Field(java.lang.reflect.Field) DefaultObjectBuilder(org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder)

Example 10 with DefaultObjectBuilder

use of org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder in project mule by mulesoft.

the class MetadataKeyIdObjectResolver method instantiateFromFieldValue.

private Object instantiateFromFieldValue(Class<?> metadataKeyType, Map<Field, String> fieldValueMap) throws MetadataResolvingException {
    try {
        DefaultObjectBuilder objectBuilder = new DefaultObjectBuilder<>(metadataKeyType);
        fieldValueMap.forEach((f, v) -> objectBuilder.addPropertyResolver(f.getName(), new StaticValueResolver<>(v)));
        return objectBuilder.build(null);
    } catch (Exception e) {
        throw buildException(format("MetadataKey object of type '%s' from the component '%s' could not be instantiated", metadataKeyType.getSimpleName(), component.getName()), e);
    }
}
Also used : StaticValueResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver) DefaultObjectBuilder(org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder) MetadataResolvingException(org.mule.runtime.api.metadata.MetadataResolvingException)

Aggregations

DefaultObjectBuilder (org.mule.runtime.module.extension.internal.runtime.objectbuilder.DefaultObjectBuilder)13 Test (org.junit.Test)4 SmallTest (org.mule.tck.size.SmallTest)4 StaticValueResolver (org.mule.runtime.module.extension.internal.runtime.resolver.StaticValueResolver)3 Field (java.lang.reflect.Field)2 ObjectType (org.mule.metadata.api.model.ObjectType)2 MuleException (org.mule.runtime.api.exception.MuleException)2 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)2 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)2 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)2 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)2 String.format (java.lang.String.format)1 Collections.emptyList (java.util.Collections.emptyList)1 LinkedHashMap (java.util.LinkedHashMap)1 Optional (java.util.Optional)1 Collectors.joining (java.util.stream.Collectors.joining)1 StringUtils.isBlank (org.apache.commons.lang3.StringUtils.isBlank)1 Before (org.junit.Before)1 TypeIdAnnotation (org.mule.metadata.api.annotation.TypeIdAnnotation)1 BaseTypeBuilder (org.mule.metadata.api.builder.BaseTypeBuilder)1