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;
}
Aggregations