KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > webflow > engine > support > NotTransitionCriteria


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.springframework.webflow.engine.support;
17
18 import java.io.Serializable JavaDoc;
19
20 import org.springframework.util.Assert;
21 import org.springframework.webflow.engine.TransitionCriteria;
22 import org.springframework.webflow.execution.RequestContext;
23
24 /**
25  * Transition criteria that negates the result of the evaluation of
26  * another criteria object.
27  *
28  * @author Keith Donald
29  */

30 public class NotTransitionCriteria implements TransitionCriteria, Serializable JavaDoc {
31
32     /**
33      * The criteria to negate.
34      */

35     private TransitionCriteria criteria;
36     
37     /**
38      * Create a new transition criteria object that will negate
39      * the result of given criteria object.
40      * @param criteria the criteria to negate
41      */

42     public NotTransitionCriteria(TransitionCriteria criteria) {
43         Assert.notNull(criteria, "The criteria object to negate is required");
44         this.criteria = criteria;
45     }
46     
47     public boolean test(RequestContext context) {
48         return !criteria.test(context);
49     }
50     
51     public String JavaDoc toString() {
52         return "[not(" + criteria + ")]";
53     }
54 }
Popular Tags