View Javadoc
1 /* 2 * Copyright (c) 2002-2003 The XDoclet Team. 3 * All rights reserved. 4 */ 5 package xdoclet.util.predicates; 6 7 import org.apache.commons.collections.Predicate; 8 9 /*** 10 * Logical Not. 11 * 12 * @author <a href="aslak.hellesoy at netcom.no">Aslak Hellesøy</a> 13 */ 14 public class Not extends CompositePredicate { 15 public void add(Predicate predicate) { 16 if (size() >= 1) { 17 throw new IllegalStateException("Only one sub-predicate allowed for not"); 18 } 19 20 super.add(predicate); 21 } 22 23 public boolean evaluate(Object o) { 24 if (size() != 1) { 25 throw new IllegalStateException("Not requires one sub-predicate"); 26 } 27 28 return !((Predicate) iterator().next()).evaluate(o); 29 } 30 }

This page was automatically generated by Maven