guava_ch

Using the Predicates.not method

Predicates.not 方法接受一个Predicate对象,并执行组成Predicate的逻辑非操作。 假设我们想要找出人口超过500,000的城市。不需要在写一个Predicate,我们可以在以存在的PopulationPredicate对象上使用Predicate.not

Predicate largeCityPredicate = Predicate.not(smallPopulationPredicate);