internal.sdmxdl.desktop.Collectors2 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdmx-dl-desktop Show documentation
Show all versions of sdmx-dl-desktop Show documentation
Easily download official statistics - Desktop
The newest version!
package internal.sdmxdl.desktop;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collector;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toList;
public final class Collectors2 {
private Collectors2() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
public static Collector> single() {
return collectingAndThen(toList(), Collectors2::getSingle);
}
public static Optional getSingle(List list) {
return list.size() == 1 ? Optional.ofNullable(list.get(0)) : Optional.empty();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy