use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.ComplexType in project mule by mulesoft.
the class ObjectTypeSchemaDelegate method registerPojoComplexType.
/**
* Registers the {@link TopLevelComplexType} associated to the given {@link ObjectType} in the current namespace
*
* @param type the {@link ObjectType} that will be represented by the registered {@link ComplexType}
* @param baseType the {@code base} for the {@link ComplexType} {@code extension} declaration
* @param description
* @return a new {@link ComplexType} declaration for the given {@link ObjectType}
*/
private ComplexType registerPojoComplexType(ObjectType type, ObjectType baseType, String description) {
String typeId = getId(type);
if (registeredComplexTypesHolders.get(typeId) != null) {
return registeredComplexTypesHolders.get(typeId).getComplexType();
}
QName base = getComplexTypeBase(type, baseType);
Collection<ObjectFieldType> fields;
if (baseType == null) {
fields = type.getFields();
} else {
fields = type.getFields().stream().filter(field -> !baseType.getFields().stream().anyMatch(other -> other.getKey().getName().getLocalPart().equals(field.getKey().getName().getLocalPart()))).collect(toList());
}
ComplexType complexType = declarePojoAsType(type, base, description, fields);
builder.getSchema().getSimpleTypeOrComplexTypeOrGroup().add(complexType);
return complexType;
}
Aggregations