Search in sources :

Example 1 with NoFixedFacet

use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.NoFixedFacet in project mule by mulesoft.

the class SchemaBuilder method createEnumSimpleType.

private LocalSimpleType createEnumSimpleType(MetadataType enumType) {
    LocalSimpleType enumValues = new LocalSimpleType();
    Restriction restriction = new Restriction();
    enumValues.setRestriction(restriction);
    restriction.setBase(STRING);
    EnumAnnotation<String> enumAnnotation = enumType.getAnnotation(EnumAnnotation.class).orElseThrow(() -> new IllegalArgumentException("Cannot obtain enum values for the given type"));
    for (String value : enumAnnotation.getValues()) {
        NoFixedFacet noFixedFacet = objectFactory.createNoFixedFacet();
        noFixedFacet.setValue(value);
        JAXBElement<NoFixedFacet> enumeration = objectFactory.createEnumeration(noFixedFacet);
        enumValues.getRestriction().getFacets().add(enumeration);
    }
    return enumValues;
}
Also used : Restriction(org.mule.runtime.module.extension.internal.capability.xml.schema.model.Restriction) LocalSimpleType(org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalSimpleType) EnumAnnotation(org.mule.metadata.api.annotation.EnumAnnotation) NoFixedFacet(org.mule.runtime.module.extension.internal.capability.xml.schema.model.NoFixedFacet)

Aggregations

EnumAnnotation (org.mule.metadata.api.annotation.EnumAnnotation)1 LocalSimpleType (org.mule.runtime.module.extension.internal.capability.xml.schema.model.LocalSimpleType)1 NoFixedFacet (org.mule.runtime.module.extension.internal.capability.xml.schema.model.NoFixedFacet)1 Restriction (org.mule.runtime.module.extension.internal.capability.xml.schema.model.Restriction)1