View Javadoc
1   /*******************************************************************************
2    * Portions created by Sebastian Thomschke are copyright (c) 2005-2011 Sebastian
3    * Thomschke.
4    * 
5    * All Rights Reserved. This program and the accompanying materials
6    * are made available under the terms of the Eclipse Public License v1.0
7    * which accompanies this distribution, and is available at
8    * http://www.eclipse.org/legal/epl-v10.html
9    * 
10   * Contributors:
11   *     Sebastian Thomschke - initial implementation.
12   *******************************************************************************/
13  package net.sf.oval.guard;
14  
15  import java.lang.annotation.Documented;
16  import java.lang.annotation.ElementType;
17  import java.lang.annotation.Retention;
18  import java.lang.annotation.RetentionPolicy;
19  import java.lang.annotation.Target;
20  
21  /**
22   * Before the annotated method is executed the expression is evaluated.<br>
23   * This evaluation happens <u>after</u> the single parameter constraints were validated
24   * and only if no parameter constraint violations were detected.
25   * <br>
26   * If constraint violations occur, the annotated method will not be executed 
27   * instead it will throw a ConstraintsViolatedException exception. 
28   * 
29   * @author Sebastian Thomschke
30   */
31  @Documented
32  @Retention(RetentionPolicy.RUNTIME)
33  @Target({ElementType.METHOD})
34  public @interface Pre
35  {
36  
37  	/**
38  	 * error code passed to the ConstraintViolation object
39  	 */
40  	String errorCode() default "net.sf.oval.guard.Pre";
41  
42  	/**
43  	 * formula in the given expression language describing the constraint. the formula must return true if the constraint is satisfied.
44  	 * <br>
45  	 * available variables are:<br>
46  	 * <b>_this</b> -&gt; the validated bean<br>
47  	 * <b>_args[]</b> -&gt; the current parameter values<br>
48  	 * additionally variables matching the parameter names are available<br>
49  	 */
50  	String expr();
51  
52  	/**
53  	 * the expression language that is used
54  	 */
55  	String lang();
56  
57  	/**
58  	 * message to be used for the ContraintsViolatedException
59  	 * 
60  	 * @see net.sf.oval.exception.ConstraintsViolatedException
61  	 */
62  	String message() default "net.sf.oval.guard.Pre.violated";
63  
64  	/**
65  	 * The associated constraint profiles.
66  	 */
67  	String[] profiles() default {};
68  
69  	/**
70  	 * severity passed to the ConstraintViolation object
71  	 */
72  	int severity() default 0;
73  }