org.archifacts.integration.c4.model.Collectors Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of archifacts-c4-model Show documentation
Show all versions of archifacts-c4-model Show documentation
archifacts C4 Model integration
The newest version!
package org.archifacts.integration.c4.model;
import java.util.Optional;
import java.util.stream.Collector;
public final class Collectors {
private Collectors() {
}
public static Collector> toOptionalSingleton() {
return java.util.stream.Collectors.collectingAndThen(
java.util.stream.Collectors.toList(),
list -> {
if (list.isEmpty()) {
return Optional.empty();
}
if (list.size() > 1) {
throw new IllegalStateException();
}
return Optional.of(list.get(0));
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy