01: /*
02: * Copyright 2004-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 org.springframework.util.Assert;
19: import org.springframework.webflow.engine.TransitionCriteria;
20: import org.springframework.webflow.execution.RequestContext;
21:
22: /**
23: * Transition criteria that negates the result of the evaluation of
24: * another criteria object.
25: *
26: * @author Keith Donald
27: */
28: public class NotTransitionCriteria implements TransitionCriteria {
29:
30: /**
31: * The criteria to negate.
32: */
33: private TransitionCriteria criteria;
34:
35: /**
36: * Create a new transition criteria object that will negate
37: * the result of given criteria object.
38: * @param criteria the criteria to negate
39: */
40: public NotTransitionCriteria(TransitionCriteria criteria) {
41: Assert.notNull(criteria,
42: "The criteria object to negate is required");
43: this .criteria = criteria;
44: }
45:
46: public boolean test(RequestContext context) {
47: return !criteria.test(context);
48: }
49:
50: public String toString() {
51: return "[not(" + criteria + ")]";
52: }
53: }
|