Java Code Examples for java.util.function.Predicate#toString()

The following examples show how to use java.util.function.Predicate#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrintablePredicate.java    From enkan with Eclipse Public License 1.0 5 votes vote down vote up
default Predicate<T> and(Predicate<? super T> other) {
    Objects.requireNonNull(other);
    Predicate<T> orig = this;
    return new PrintablePredicate<T>() {
        @Override
        public boolean test(T t) {
            return orig.test(t) && other.test(t);
        }

        @Override
        public String toString() {
            return orig.toString() + " && " + other.toString();
        }
    };
}
 
Example 2
Source File: PrintablePredicate.java    From enkan with Eclipse Public License 1.0 5 votes vote down vote up
default Predicate<T> or(Predicate<? super T> other) {
    Objects.requireNonNull(other);
    Predicate<T> orig = this;
    return new PrintablePredicate<T>() {
        @Override
        public boolean test(T t) {
            return orig.test(t) || other.test(t);
        }

        @Override
        public String toString() {
            return "(" + orig.toString() + ") || (" + other.toString() + ")";
        }
    };
}
 
Example 3
Source File: PrintablePredicate.java    From enkan with Eclipse Public License 1.0 5 votes vote down vote up
@Override
default Predicate<T> negate() {
    Predicate<T> orig = this;
    return new PrintablePredicate<T>() {
        @Override
        public boolean test(T s) {
            return !orig.test(s);
        }

        @Override
        public String toString() {
            return "!" + orig.toString();
        }
    };
}