functionalj.stream.StreamPlusUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionalj-core Show documentation
Show all versions of functionalj-core Show documentation
The module for FunctionalJ Core.
package functionalj.stream;
import static functionalj.functions.ObjFuncs.notEqual;
import static functionalj.stream.ZipWithOption.AllowUnpaired;
import static java.lang.Boolean.TRUE;
public class StreamPlusUtils {
public static boolean equals(AsStreamPlus stream1, AsStreamPlus stream2) {
return !stream1
.streamPlus()
.zipWith (stream2.streamPlus(), AllowUnpaired, notEqual())
.filter (TRUE::equals)
.findAny ()
.isPresent();
}
public static int hashCode(AsStreamPlus stream) {
return stream
.streamPlus()
.mapToInt(e -> (e == null) ? 0 : e.hashCode())
.reduce(1, (h, eh) -> 31*h + eh);
}
public static String toString(AsStreamPlus stream) {
return "[" + stream.join(", ") + "]";
}
}