org.defendev.common.stream.Streams Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-jdk Show documentation
Show all versions of common-jdk Show documentation
Common utils purely based on JDK and no other dependencies. Only exception being for org.jetbrains:annotations for building stratgic Kotlin language compatibility.Another only-exception is Apache Commons Lang3.
The newest version!
package org.defendev.common.stream;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.stream.Stream;
import static java.util.Objects.isNull;
public class Streams {
public static Stream stream(Collection collection) {
return isNull(collection) ?
Stream.empty()
: collection.stream();
}
public static Stream stream(Enumeration enumeration) {
return isNull(enumeration) ?
Stream.empty()
: Collections.list(enumeration).stream();
}
/* TODO: possibly consider variant with Iterable */
}