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

org.codehaus.httpcache4j.util.OptionalUtils Maven / Gradle / Ivy

The newest version!
package org.codehaus.httpcache4j.util;

import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;

public class OptionalUtils {
    public static  Stream stream(Optional opt) {
        return opt.isPresent() ? Stream.of(opt.get()) : Stream.empty();
    }

    public static  boolean exists(Optional opt, Predicate p) {
        return opt.filter(p).isPresent();
    }

    public static  boolean forall(Optional opt, Predicate p) {
        return stream(opt).allMatch(p);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy