use of org.mule.runtime.api.meta.model.declaration.fluent.AbstractParameterDeclaration in project mule by mulesoft.
the class ParameterLayoutOrderDeclarationEnricher method addMissingParameterOrders.
private int addMissingParameterOrders(List<AbstractParameterDeclaration> declarations) {
AtomicInteger minOrder = new AtomicInteger(INITIAL_ORDER);
Set<Integer> takenOrders = new HashSet<>();
List<AbstractParameterDeclaration> nonOrderedParams = new ArrayList<>();
declarations.forEach(param -> {
LayoutModel layoutModel = param.getLayoutModel();
if (layoutModel != null && layoutModel.getOrder().isPresent()) {
takenOrders.add(layoutModel.getOrder().get());
minOrder.set(min(layoutModel.getOrder().get(), minOrder.get()));
} else {
nonOrderedParams.add(param);
}
});
AtomicInteger currentOrder = new AtomicInteger(INITIAL_ORDER);
nonOrderedParams.forEach(param -> param.setLayoutModel(builderFrom(param.getLayoutModel()).order(getNextOrder(currentOrder, takenOrders)).build()));
return minOrder.get();
}
Aggregations