Botre Posted April 9, 2016 Share Posted April 9, 2016 (edited) A very basic snippet, I keep seeing people rewriting negations manually way too often. Allows to you create inversions/negations of filters. Example final Filter<String> IS_EMPTY = s -> s.isEmpty(); final Filter<String> IS_NOT_EMPTY = negate(IS_EMPTY); Snippet /** * Returns a filter that represents the logical negation of the supplied filter. * * @return a filter that represents the logical negation of the supplied filter */ public static final <T> Filter<T> negate(Filter<T> filter) { return e -> !filter.match(e); } Edited April 9, 2016 by Botre 1 Quote Link to comment Share on other sites More sharing options...
DragonAlpha Posted April 9, 2016 Share Posted April 9, 2016 This is very useful. Quote Link to comment Share on other sites More sharing options...
RamSkulls Posted April 9, 2016 Share Posted April 9, 2016 Ty Quote Link to comment Share on other sites More sharing options...
amkate2 Posted April 9, 2016 Share Posted April 9, 2016 omg you saved me x: Quote Link to comment Share on other sites More sharing options...