All Downloads are FREE. Search and download functionalities are using the official Maven repository.

functionalj.stream.StreamPlusUtils Maven / Gradle / Ivy

There is a newer version: 1.0.17
Show newest version
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(", ") + "]";
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy