Search in sources :

Example 6 with ObjectFieldType

use of org.mule.metadata.api.model.ObjectFieldType in project mule by mulesoft.

the class InputParametersTypeModelValidator method validateType.

private void validateType(String message, NamedObject namedObject, MetadataType type, ProblemsReporter problems, Set<Class<?>> validatedTypes) {
    ReflectionCache reflectionCache = new ReflectionCache();
    getClassForValidation(type).ifPresent(parameterType -> type.accept(new MetadataTypeVisitor() {

        @Override
        public void visitObject(ObjectType objectType) {
            if (validatedTypes.add(parameterType)) {
                Collection<ObjectFieldType> parameters = objectType.getFields();
                Set<String> fieldsWithGetters = getFieldsWithGetters(parameterType, reflectionCache).stream().map(TypeUtils::getAlias).map(String::toLowerCase).collect(toSet());
                Set<String> parameterWithoutGetters = parameters.stream().filter(p -> {
                    StereotypeTypeAnnotation stereotypes = p.getAnnotation(StereotypeTypeAnnotation.class).orElse(null);
                    return stereotypes != null ? stereotypes.getAllowedStereotypes().isEmpty() : true;
                }).map(f -> f.getKey().getName().getLocalPart()).filter(fieldName -> !fieldsWithGetters.contains(fieldName.toLowerCase())).collect(toSet());
                if (!parameterWithoutGetters.isEmpty()) {
                    problems.addError(new Problem(namedObject, format("%s of type '%s' which contains fields (%s) that doesn't have the corresponding getter methods or getter methods that doesn't correspond to any of the present fields", message, parameterType.getName(), parameterWithoutGetters.stream().collect(joining(", ")))));
                }
            }
        }

        @Override
        public void visitArrayType(ArrayType arrayType) {
            validateType(message, namedObject, arrayType.getType(), problems, validatedTypes);
        }
    }));
}
Also used : Optional.empty(java.util.Optional.empty) StereotypeTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.StereotypeTypeAnnotation) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) NamedObject(org.mule.runtime.api.meta.NamedObject) ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) JAVA(org.mule.metadata.api.model.MetadataFormat.JAVA) HashSet(java.util.HashSet) SourceModel(org.mule.runtime.api.meta.model.source.SourceModel) ArrayType(org.mule.metadata.api.model.ArrayType) IdempotentExtensionWalker(org.mule.runtime.api.meta.model.util.IdempotentExtensionWalker) Problem(org.mule.runtime.extension.api.loader.Problem) Collectors.toSet(java.util.stream.Collectors.toSet) IntrospectionUtils.getFieldsWithGetters(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getFieldsWithGetters) TypeUtils(org.mule.runtime.extension.api.declaration.type.TypeUtils) ExtensionModelValidator(org.mule.runtime.extension.api.loader.ExtensionModelValidator) ObjectType(org.mule.metadata.api.model.ObjectType) ProblemsReporter(org.mule.runtime.extension.api.loader.ProblemsReporter) Collection(java.util.Collection) Set(java.util.Set) ReflectionCache(org.mule.runtime.module.extension.internal.util.ReflectionCache) String.format(java.lang.String.format) Collectors.joining(java.util.stream.Collectors.joining) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ExtensionMetadataTypeUtils.getType(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getType) SourceCallbackModel(org.mule.runtime.api.meta.model.source.SourceCallbackModel) ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType) NameUtils.getComponentModelTypeName(org.mule.runtime.extension.api.util.NameUtils.getComponentModelTypeName) MetadataType(org.mule.metadata.api.model.MetadataType) Optional(java.util.Optional) ArrayType(org.mule.metadata.api.model.ArrayType) ObjectType(org.mule.metadata.api.model.ObjectType) ReflectionCache(org.mule.runtime.module.extension.internal.util.ReflectionCache) StereotypeTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.StereotypeTypeAnnotation) Problem(org.mule.runtime.extension.api.loader.Problem) ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType) TypeUtils(org.mule.runtime.extension.api.declaration.type.TypeUtils) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor)

Example 7 with ObjectFieldType

use of org.mule.metadata.api.model.ObjectFieldType in project mule by mulesoft.

the class NullSafeModelValidator method validate.

@Override
public void validate(ExtensionModel extensionModel, ProblemsReporter problemsReporter) {
    ReflectionCache reflectionCache = new ReflectionCache();
    TypeLoader typeLoader = ExtensionsTypeLoaderFactory.getDefault().createTypeLoader();
    new ExtensionWalker() {

        @Override
        public void onParameter(ParameterizedModel owner, ParameterGroupModel groupModel, ParameterModel model) {
            model.getType().accept(new MetadataTypeVisitor() {

                @Override
                public void visitObject(ObjectType objectType) {
                    if (objectType.getMetadataFormat().equals(JAVA) && !isMap(objectType)) {
                        objectType.getAnnotation(TypeIdAnnotation.class).map(TypeIdAnnotation::getValue).ifPresent(typeId -> typeLoader.load(typeId).ifPresent(fieldMetadataType -> objectType.getFields().stream().filter(f -> f.getAnnotation(NullSafeTypeAnnotation.class).isPresent()).forEach(f -> validateField(getLocalPart(f), f, getType(fieldMetadataType), f.getAnnotation(NullSafeTypeAnnotation.class).get()))));
                    }
                }

                private void validateField(String fieldName, ObjectFieldType field, Class<?> declaringClass, NullSafeTypeAnnotation nullSafeTypeAnnotation) {
                    Class<?> nullSafeType = nullSafeTypeAnnotation.getType();
                    Class<?> fieldType = getType(field.getValue());
                    boolean hasDefaultOverride = nullSafeTypeAnnotation.hasDefaultOverride();
                    field.getValue().accept(new BasicTypeMetadataVisitor() {

                        @Override
                        protected void visitBasicType(MetadataType metadataType) {
                            problemsReporter.addError(new Problem(extensionModel, format("Field '%s' in class '%s' is annotated with '@%s' but is of type '%s'. That annotation can only be " + "used with complex types (Pojos, Lists, Maps)", fieldName, declaringClass.getName(), NullSafe.class.getSimpleName(), fieldType.getName())));
                        }

                        @Override
                        public void visitArrayType(ArrayType arrayType) {
                            if (hasDefaultOverride) {
                                problemsReporter.addError(new Problem(extensionModel, format("Field '%s' in class '%s' is annotated with '@%s' is of type '%s'" + " but a 'defaultImplementingType' was provided." + " Type override is not allowed for Collections", fieldName, declaringClass.getName(), NullSafe.class.getSimpleName(), fieldType.getName())));
                            }
                        }

                        @Override
                        public void visitObject(ObjectType objectType) {
                            String requiredFields = objectType.getFields().stream().filter(f -> f.isRequired() && !isFlattenedParameterGroup(f)).map(MetadataTypeUtils::getLocalPart).collect(joining(", "));
                            if (!isBlank(requiredFields) && isCompiletime(extensionModel)) {
                                problemsReporter.addError(new Problem(model, format("Class '%s' cannot be used with '@%s' parameter since it contains non optional fields: [%s]", getId(objectType).orElse(""), NullSafe.class.getSimpleName(), requiredFields)));
                            }
                            if (objectType.isOpen()) {
                                if (hasDefaultOverride) {
                                    problemsReporter.addError(new Problem(model, format("Field '%s' in class '%s' is annotated with '@%s' is of type '%s'" + " but a 'defaultImplementingType' was provided." + " Type override is not allowed for Maps", fieldName, declaringClass.getName(), NullSafe.class.getSimpleName(), fieldType.getName())));
                                }
                                return;
                            }
                            if (hasDefaultOverride && isInstantiable(fieldType, reflectionCache)) {
                                problemsReporter.addError(new Problem(model, format("Field '%s' in class '%s' is annotated with '@%s' is of concrete type '%s'," + " but a 'defaultImplementingType' was provided." + " Type override is not allowed for concrete types", fieldName, declaringClass.getName(), NullSafe.class.getSimpleName(), fieldType.getName())));
                            }
                            if (!isInstantiable(nullSafeType, reflectionCache)) {
                                problemsReporter.addError(new Problem(model, format("Field '%s' in class '%s' is annotated with '@%s' but is of type '%s'. That annotation can only be " + "used with complex instantiable types (Pojos, Lists, Maps)", fieldName, declaringClass.getName(), NullSafe.class.getSimpleName(), nullSafeType.getName())));
                            }
                            if (hasDefaultOverride && !fieldType.isAssignableFrom(nullSafeType)) {
                                problemsReporter.addError(new Problem(model, format("Field '%s' in class '%s' is annotated with '@%s' of type '%s', but provided type '%s" + " is not a subtype of the parameter's type", fieldName, declaringClass.getName(), NullSafe.class.getSimpleName(), fieldType.getName(), nullSafeType.getName())));
                            }
                        }
                    });
                }
            });
        }
    }.walk(extensionModel);
}
Also used : ExtensionMetadataTypeUtils.getId(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getId) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) ExtensionsTypeLoaderFactory(org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory) JAVA(org.mule.metadata.api.model.MetadataFormat.JAVA) MetadataTypeUtils(org.mule.metadata.api.utils.MetadataTypeUtils) ExtensionMetadataTypeUtils.isFlattenedParameterGroup(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isFlattenedParameterGroup) ModelValidationUtils.isCompiletime(org.mule.runtime.module.extension.internal.loader.validation.ModelValidationUtils.isCompiletime) ArrayType(org.mule.metadata.api.model.ArrayType) BasicTypeMetadataVisitor(org.mule.metadata.api.visitor.BasicTypeMetadataVisitor) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) IntrospectionUtils.isInstantiable(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.isInstantiable) Problem(org.mule.runtime.extension.api.loader.Problem) MetadataTypeUtils.getLocalPart(org.mule.metadata.api.utils.MetadataTypeUtils.getLocalPart) TypeIdAnnotation(org.mule.metadata.api.annotation.TypeIdAnnotation) ExtensionModelValidator(org.mule.runtime.extension.api.loader.ExtensionModelValidator) ExtensionMetadataTypeUtils.isMap(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.isMap) ObjectType(org.mule.metadata.api.model.ObjectType) ParameterizedModel(org.mule.runtime.api.meta.model.parameter.ParameterizedModel) ProblemsReporter(org.mule.runtime.extension.api.loader.ProblemsReporter) NullSafeTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.NullSafeTypeAnnotation) ReflectionCache(org.mule.runtime.module.extension.internal.util.ReflectionCache) String.format(java.lang.String.format) Collectors.joining(java.util.stream.Collectors.joining) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) TypeLoader(org.mule.metadata.api.TypeLoader) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) ExtensionWalker(org.mule.runtime.api.meta.model.util.ExtensionWalker) NullSafe(org.mule.runtime.extension.api.annotation.param.NullSafe) MetadataType(org.mule.metadata.api.model.MetadataType) JavaTypeUtils.getType(org.mule.metadata.java.api.utils.JavaTypeUtils.getType) ReflectionCache(org.mule.runtime.module.extension.internal.util.ReflectionCache) ExtensionWalker(org.mule.runtime.api.meta.model.util.ExtensionWalker) MetadataType(org.mule.metadata.api.model.MetadataType) TypeLoader(org.mule.metadata.api.TypeLoader) NullSafeTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.NullSafeTypeAnnotation) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) MetadataTypeUtils(org.mule.metadata.api.utils.MetadataTypeUtils) BasicTypeMetadataVisitor(org.mule.metadata.api.visitor.BasicTypeMetadataVisitor) ArrayType(org.mule.metadata.api.model.ArrayType) ObjectType(org.mule.metadata.api.model.ObjectType) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) ParameterizedModel(org.mule.runtime.api.meta.model.parameter.ParameterizedModel) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) Problem(org.mule.runtime.extension.api.loader.Problem) ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType)

Example 8 with ObjectFieldType

use of org.mule.metadata.api.model.ObjectFieldType in project mule by mulesoft.

the class IntrospectionUtils method collectRelativeClasses.

/**
 * Given a {@link MetadataType} it adds all the {@link Class} that are related from that type. This includes generics of an
 * {@link ArrayType}, open restriction of an {@link ObjectType} as well as its fields.
 *
 * @param type {@link MetadataType} to inspect
 * @param extensionClassLoader extension class loader
 * @return {@link Set<Class<?>>} with the classes reachable from the {@code type}
 */
public static Set<Class<?>> collectRelativeClasses(MetadataType type, ClassLoader extensionClassLoader) {
    Set<Class<?>> relativeClasses = new HashSet<>();
    type.accept(new MetadataTypeVisitor() {

        @Override
        public void visitArrayType(ArrayType arrayType) {
            arrayType.getType().accept(this);
        }

        @Override
        public void visitObjectField(ObjectFieldType objectFieldType) {
            objectFieldType.getValue().accept(this);
        }

        @Override
        public void visitObject(ObjectType objectType) {
            if (objectType.getMetadataFormat() != JAVA) {
                return;
            }
            final Class<Object> clazz = getType(objectType).orElse(null);
            if (clazz == null || relativeClasses.contains(clazz)) {
                return;
            }
            Optional<ClassInformationAnnotation> classInformation = objectType.getAnnotation(ClassInformationAnnotation.class);
            if (classInformation.isPresent()) {
                classInformation.get().getGenericTypes().forEach(generic -> relativeClasses.add(loadClass(generic, extensionClassLoader)));
            }
            relativeClasses.add(clazz);
            objectType.getFields().stream().forEach(objectFieldType -> objectFieldType.accept(this));
            objectType.getOpenRestriction().ifPresent(t -> t.accept(this));
        }

        @Override
        public void visitString(StringType stringType) {
            if (stringType.getMetadataFormat() == JAVA && isEnum(stringType)) {
                getType(stringType).ifPresent(relativeClasses::add);
            }
        }
    });
    return relativeClasses;
}
Also used : ArrayType(org.mule.metadata.api.model.ArrayType) FieldElement(org.mule.runtime.module.extension.api.loader.java.type.FieldElement) READ_ONLY(org.mule.runtime.module.extension.api.loader.java.type.PropertyElement.Accessibility.READ_ONLY) ParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration) Message(org.mule.runtime.api.message.Message) Optional.of(java.util.Optional.of) RequireNameField(org.mule.runtime.module.extension.internal.loader.java.property.RequireNameField) ImplementingParameterModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingParameterModelProperty) TypeElement(javax.lang.model.element.TypeElement) ClassUtils(org.mule.runtime.core.api.util.ClassUtils) DeclaringMemberModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.DeclaringMemberModelProperty) ArrayUtils.isEmpty(org.apache.commons.lang3.ArrayUtils.isEmpty) Type(org.mule.runtime.module.extension.api.loader.java.type.Type) ArrayType(org.mule.metadata.api.model.ArrayType) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Objects.isNull(java.util.Objects.isNull) LiteralTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.LiteralTypeAnnotation) ClassTypeLoader(org.mule.metadata.api.ClassTypeLoader) ModelProperty(org.mule.runtime.api.meta.model.ModelProperty) Startable(org.mule.runtime.api.lifecycle.Startable) Collectors.toImmutableList(org.mule.runtime.api.util.collection.Collectors.toImmutableList) ObjectType(org.mule.metadata.api.model.ObjectType) ConnectionProvider(org.mule.runtime.api.connection.ConnectionProvider) Member(java.lang.reflect.Member) Set(java.util.Set) ParameterResolverTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.ParameterResolverTypeAnnotation) Element(javax.lang.model.element.Element) JavaTypeUtils.getId(org.mule.metadata.java.api.utils.JavaTypeUtils.getId) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) IntrospectionException(java.beans.IntrospectionException) BaseTypeBuilder.create(org.mule.metadata.api.builder.BaseTypeBuilder.create) IllegalConfigurationModelDefinitionException(org.mule.runtime.extension.api.exception.IllegalConfigurationModelDefinitionException) ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType) StringType(org.mule.metadata.api.model.StringType) ParameterResolver(org.mule.runtime.extension.api.runtime.parameter.ParameterResolver) Stream(java.util.stream.Stream) PropertyDescriptor(java.beans.PropertyDescriptor) MetadataType(org.mule.metadata.api.model.MetadataType) InjectedFieldModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.InjectedFieldModelProperty) Expression(org.mule.runtime.extension.api.annotation.Expression) AnnotatedElement(java.lang.reflect.AnnotatedElement) Optional.empty(java.util.Optional.empty) MetadataTypeUtils.isObjectType(org.mule.metadata.api.utils.MetadataTypeUtils.isObjectType) AnyType(org.mule.metadata.api.model.AnyType) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) VariableElement(javax.lang.model.element.VariableElement) Preconditions.checkArgument(org.mule.runtime.api.util.Preconditions.checkArgument) Modifier.isStatic(java.lang.reflect.Modifier.isStatic) Supplier(java.util.function.Supplier) BaseTypeBuilder(org.mule.metadata.api.builder.BaseTypeBuilder) ArrayList(java.util.ArrayList) Introspector(java.beans.Introspector) DeclaredType(javax.lang.model.type.DeclaredType) ParameterGroup(org.mule.runtime.extension.api.annotation.param.ParameterGroup) LinkedHashSet(java.util.LinkedHashSet) Disposable(org.mule.runtime.api.lifecycle.Disposable) ParameterizedModel(org.mule.runtime.api.meta.model.parameter.ParameterizedModel) DataType(org.mule.runtime.api.metadata.DataType) Field(java.lang.reflect.Field) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) TypedValue(org.mule.runtime.api.metadata.TypedValue) ExtensionMetadataTypeUtils.getType(org.mule.runtime.extension.api.util.ExtensionMetadataTypeUtils.getType) Modifier.isPublic(java.lang.reflect.Modifier.isPublic) ParameterizedType(java.lang.reflect.ParameterizedType) Stoppable(org.mule.runtime.api.lifecycle.Stoppable) ExtensionWalker(org.mule.runtime.api.meta.model.util.ExtensionWalker) Reference(org.mule.runtime.api.util.Reference) RefName(org.mule.runtime.extension.api.annotation.param.RefName) CollectionUtils.isEmpty(org.apache.commons.collections.CollectionUtils.isEmpty) ReflectionUtils(org.reflections.ReflectionUtils) ReflectionUtils.getAllFields(org.reflections.ReflectionUtils.getAllFields) SubTypesModel(org.mule.runtime.api.meta.model.SubTypesModel) HasOutputModel(org.mule.runtime.api.meta.model.HasOutputModel) TargetModelProperty(org.mule.runtime.extension.internal.property.TargetModelProperty) NamedObject(org.mule.runtime.api.meta.NamedObject) Source(org.mule.runtime.extension.api.runtime.source.Source) VoidType(org.mule.metadata.api.model.VoidType) MetadataTypeUtils.isEnum(org.mule.metadata.api.utils.MetadataTypeUtils.isEnum) DefaultEncodingModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.DefaultEncodingModelProperty) ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) SUPPORTED(org.mule.runtime.api.meta.ExpressionSupport.SUPPORTED) ResolvableType(org.springframework.core.ResolvableType) Pair(org.mule.runtime.api.util.Pair) Method(java.lang.reflect.Method) Collectors.toSet(java.util.stream.Collectors.toSet) Collections.reverse(java.util.Collections.reverse) Collections.emptyList(java.util.Collections.emptyList) Collection(java.util.Collection) ClassInformationAnnotation(org.mule.metadata.java.api.annotation.ClassInformationAnnotation) Types(javax.lang.model.util.Types) String.format(java.lang.String.format) List(java.util.List) Modifier(java.lang.reflect.Modifier) Annotation(java.lang.annotation.Annotation) Optional(java.util.Optional) TypeVariable(javax.lang.model.type.TypeVariable) EnrichableModel(org.mule.runtime.api.meta.model.EnrichableModel) Arrays.stream(java.util.Arrays.stream) IllegalModelDefinitionException(org.mule.runtime.extension.api.exception.IllegalModelDefinitionException) MessageMetadataTypeBuilder(org.mule.metadata.message.api.MessageMetadataTypeBuilder) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) Alias(org.mule.runtime.extension.api.annotation.Alias) TypeGeneric(org.mule.runtime.module.extension.api.loader.java.type.TypeGeneric) ComponentModel(org.mule.runtime.api.meta.model.ComponentModel) JAVA(org.mule.metadata.api.model.MetadataFormat.JAVA) MetadataKeyId(org.mule.runtime.extension.api.annotation.metadata.MetadataKeyId) Ignore(org.mule.runtime.extension.api.annotation.Ignore) HashSet(java.util.HashSet) Collectors.toCollection(java.util.stream.Collectors.toCollection) MethodElement(org.mule.runtime.module.extension.api.loader.java.type.MethodElement) ImmutableList(com.google.common.collect.ImmutableList) Literal(org.mule.runtime.extension.api.runtime.parameter.Literal) ParameterGroupModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ParameterGroupModelProperty) LinkedList(java.util.LinkedList) Parameter(org.mule.runtime.extension.api.annotation.param.Parameter) TypedValueTypeAnnotation(org.mule.runtime.extension.api.declaration.type.annotation.TypedValueTypeAnnotation) AccessibleObject(java.lang.reflect.AccessibleObject) Iterator(java.util.Iterator) ElementKind(javax.lang.model.element.ElementKind) PUBLIC(javax.lang.model.element.Modifier.PUBLIC) ExpressionSupport(org.mule.runtime.api.meta.ExpressionSupport) ExecutableElement(javax.lang.model.element.ExecutableElement) READ_WRITE(org.mule.runtime.module.extension.api.loader.java.type.PropertyElement.Accessibility.READ_WRITE) Initialisable(org.mule.runtime.api.lifecycle.Initialisable) Result(org.mule.runtime.extension.api.runtime.operation.Result) DefaultEncoding(org.mule.runtime.extension.api.annotation.param.DefaultEncoding) Collectors.toList(java.util.stream.Collectors.toList) TypeMirror(javax.lang.model.type.TypeMirror) BaseDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.BaseDeclaration) METHOD(javax.lang.model.element.ElementKind.METHOD) PagingProvider(org.mule.runtime.extension.api.runtime.streaming.PagingProvider) ProcessingEnvironment(javax.annotation.processing.ProcessingEnvironment) ComponentLocation(org.mule.runtime.api.component.location.ComponentLocation) MuleExtensionAnnotationParser(org.mule.runtime.module.extension.internal.loader.java.MuleExtensionAnnotationParser) ImplementingTypeModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingTypeModelProperty) ObjectType(org.mule.metadata.api.model.ObjectType) MetadataTypeUtils.isObjectType(org.mule.metadata.api.utils.MetadataTypeUtils.isObjectType) Optional(java.util.Optional) StringType(org.mule.metadata.api.model.StringType) ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType) MetadataTypeVisitor(org.mule.metadata.api.visitor.MetadataTypeVisitor) ClassInformationAnnotation(org.mule.metadata.java.api.annotation.ClassInformationAnnotation) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Example 9 with ObjectFieldType

use of org.mule.metadata.api.model.ObjectFieldType in project mule by mulesoft.

the class QueryMetadataTestCase method assertCircleType.

private void assertCircleType(ObjectType fields) {
    assertThat(fields.getFields(), hasSize(1));
    ObjectFieldType field = fields.getFields().iterator().next();
    assertThat(field.getKey().getName().getLocalPart(), is("id"));
    assertThat(field.getValue(), is(instanceOf(NumberType.class)));
}
Also used : ObjectFieldType(org.mule.metadata.api.model.ObjectFieldType)

Aggregations

ObjectFieldType (org.mule.metadata.api.model.ObjectFieldType)9 MetadataType (org.mule.metadata.api.model.MetadataType)7 ObjectType (org.mule.metadata.api.model.ObjectType)7 String.format (java.lang.String.format)6 ArrayType (org.mule.metadata.api.model.ArrayType)6 MetadataTypeVisitor (org.mule.metadata.api.visitor.MetadataTypeVisitor)6 Optional (java.util.Optional)5 JAVA (org.mule.metadata.api.model.MetadataFormat.JAVA)5 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)5 Collection (java.util.Collection)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 ParameterGroupModel (org.mule.runtime.api.meta.model.parameter.ParameterGroupModel)4 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)4 ParameterizedModel (org.mule.runtime.api.meta.model.parameter.ParameterizedModel)4 ImmutableList (com.google.common.collect.ImmutableList)3 Field (java.lang.reflect.Field)3 Reference (org.mule.runtime.api.util.Reference)3 IntrospectionException (java.beans.IntrospectionException)2 Introspector (java.beans.Introspector)2