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   * After the annotated method has been executed the condition is evaluated.<br>
23   * <br>
24   * In case of constraint violations the method will throw an ConstraintsViolatedException.
25   *
26   * @author Sebastian Thomschke
27   */
28  @Documented
29  @Retention(RetentionPolicy.RUNTIME)
30  @Target({ElementType.METHOD})
31  public @interface Post
32  {
33  	/**
34  	 * error code passed to the ConstraintViolation object
35  	 */
36  	String errorCode() default "net.sf.oval.guard.Post";
37  
38  	/**
39  	 * Formula in the given expression language describing the constraint. the formula must return true if the constraint is satisfied.
40  	 * <br>
41  	 * available variables are:<br>
42  	 * <b>_args[]</b> -&gt; the current parameter values<br>
43  	 * <b>_old</b> -&gt; the old values<br>
44  	 * <b>_returns</b> -&gt; the method's return value
45  	 * <b>_this</b> -&gt; the validated bean<br>
46  	 * additionally variables named accordingly to the parameters are available<br>
47  	 */
48  	String expr();
49  
50  	/**
51  	 * the expression language that is used
52  	 */
53  	String lang();
54  
55  	/**
56  	 * message to be used for the ContraintsViolatedException
57  	 * 
58  	 * @see net.sf.oval.exception.ConstraintsViolatedException
59  	 */
60  	String message() default "net.sf.oval.guard.Post.violated";
61  
62  	/**
63  	 * Formula that is evaluated prior method execution.<br>
64  	 * The returned value can later be accessed in the constraint expression via the variable <b>_old</b>
65  	 */
66  	String old() default "";
67  
68  	/**
69  	 * The associated constraint profiles.
70  	 */
71  	String[] profiles() default {};
72  
73  	/**
74  	 * severity passed to the ConstraintViolation object
75  	 */
76  	int severity() default 0;
77  }