List of usage examples for java.util.function Predicate negate
default Predicate<T> negate()
From source file:Main.java
public static void main(String[] args) { Predicate<String> i = (s) -> s.length() > 5; System.out.println(i.negate().test("java2s.com ")); }
From source file:Main.java
public static void main(String[] args) { List<String> names = Arrays.asList("Chris", "HTML", "XML", "CSS", ""); Stream<String> s = names.stream(); Predicate<String> isEmpty = String::isEmpty; Predicate<String> notEmpty = isEmpty.negate(); System.out.println(s.filter(notEmpty).collect(Collectors.toList())); }
From source file:Main.java
public static void main(String... args) { Predicate<String> predicate = (s) -> s.length() > 0; predicate.test("foo"); // true predicate.negate().test("foo"); // false }
From source file:Main.java
public static void main(String[] argv) throws Exception { List<String> argList = Arrays.asList("help", "v"); Predicate<String> isHelp = (s) -> s.matches("(h|help)"); argList = argList.stream().filter(isHelp.negate()).collect(Collectors.toList()); System.out.println(argList);/*from www .j a va 2 s .c o m*/ }
From source file:Main.java
public static void main(String... args) { Predicate<String> isEmpty = String::isEmpty; System.out.println(isEmpty.test("")); System.out.println(isEmpty.negate().test("")); }
From source file:Main.java
public static void main(String... args) { Predicate<Boolean> nonNull = Objects::isNull; System.out.println(nonNull.test(true)); System.out.println(nonNull.negate().test(false)); }
From source file:Main.java
public static void main(String... args) { Predicate<Boolean> nonNull = Objects::nonNull; System.out.println(nonNull.test(true)); System.out.println(nonNull.negate().test(false)); }
From source file:Main.java
public static void main(String... args) { Predicate<String> isEmpty = String::isEmpty; System.out.println(isEmpty.test("")); Predicate<String> isNotEmpty = isEmpty.negate(); System.out.println(isNotEmpty.test("")); }
From source file:Main.java
public static void main(String[] args) { Predicate<Student> isPaidEnough = e -> e.gpa > 1; Predicate<Student> isExperiencedEnough = e -> e.id < 10; List<Student> students = Arrays.asList(new Student(1, 3, "John"), new Student(2, 4, "Jane"), new Student(3, 3, "Jack")); System.out.println(findStudents(students, isPaidEnough)); System.out.println(findStudents(students, isExperiencedEnough)); System.out.println(findStudents(students, isExperiencedEnough.negate())); Student somebody = students.get(0);//from www. j a v a2 s .c o m System.out.println(findStudents(students, Predicate.<Student>isEqual(somebody))); }
From source file:io.github.jeddict.jcode.util.JavaUtil.java
public static <R> Predicate<R> not(Predicate<R> predicate) { return predicate.negate(); }