01: /*******************************************************************************
02: * Portions created by Sebastian Thomschke are copyright (c) 2005-2007 Sebastian
03: * Thomschke.
04: *
05: * All Rights Reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * Sebastian Thomschke - initial implementation.
12: *******************************************************************************/package net.sf.oval.constraint;
13:
14: import java.lang.annotation.Documented;
15: import java.lang.annotation.ElementType;
16: import java.lang.annotation.Retention;
17: import java.lang.annotation.RetentionPolicy;
18: import java.lang.annotation.Target;
19:
20: import net.sf.oval.ConstraintViolation;
21: import net.sf.oval.configuration.annotation.Constraint;
22:
23: /**
24: * Check if evaluating the expression in the specified expression language returns true.<br>
25: *
26: * @author Sebastian Thomschke
27: */
28: @Documented
29: @Retention(RetentionPolicy.RUNTIME)
30: @Target({ElementType.FIELD,ElementType.PARAMETER,ElementType.METHOD,ElementType.TYPE})
31: @Constraint(checkWith=AssertCheck.class)
32: public @interface Assert {
33:
34: /**
35: * failure code passed to the ConstraintViolation object
36: */
37: String errorCode() default "net.sf.oval.constraints.Assert";
38:
39: /**
40: * formula in the given expression language describing the constraint. the formula must return true if the constraint is satisfied.
41: * <br>
42: * available variables are:<br>
43: * <b>_this</b> -> the validated bean<br>
44: * <b>_value</b> -> the value to validate (e.g. the field value, parameter value, method return value, or the validated bean for object level constraints)
45: */
46: String expr();
47:
48: /**
49: * the expression language that is used, e.g. "bsh" / "beanshell", "groovy", or "js" / "javascript".
50: */
51: String lang();
52:
53: /**
54: * message to be used for constructing the ConstraintViolation object
55: *
56: * @see ConstraintViolation
57: */
58: String message() default "net.sf.oval.constraints.Assert.violated";
59:
60: /**
61: * severity passed to the ConstraintViolation object
62: */
63: int severity() default 0;
64:
65: /**
66: * The associated validation profiles.
67: */
68: String[] profiles() default {};
69: }
|