var result = component.getChildComponents().stream()
.sorted(Comparator.comparingInt(TextComponent::getCountChildElements))
.collect(Collectors.toList());
component.getChildComponents().clear();
component.getChildComponents().addAll(result);
public void setChildComponents(List<TextComponent> childComponents) {
this.childComponents = childComponents;
}
class Example {
public static void main(String[] args) {
var licenses = List.of(
new License(1, true),
new License(2, false),
new License(3, true)
);
var licenseMap = licenses.stream()
.collect(Collectors.toMap(License::getId, License::isActive));
}
@Getter
@RequiredArgsConstructor
private static class License {
private final Integer id;
private final boolean isActive;
}
}