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.constraint.exclusion;
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  import net.sf.oval.configuration.annotation.Exclusion;
22  
23  /**
24   * Allows a value to be nullable.
25   * 
26   * @author Sebastian Thomschke
27   */
28  @Documented
29  @Retention(RetentionPolicy.RUNTIME)
30  @Target({ElementType.PARAMETER})
31  @Exclusion(excludeWith = NullableExclusion.class)
32  public @interface Nullable
33  {
34  	/**
35  	 * The associated constraint profiles.
36  	 */
37  	String[] profiles() default {};
38  
39  	/**
40  	 * Formula returning <code>true</code> if this constraint exclusion shall be active and
41  	 * <code>false</code> if it shall be ignored for the current validation.
42  	 * <p>
43  	 * <b>Important:</b> The formula must be prefixed with the name of the scripting language that is used.
44  	 * E.g. <code>groovy:_this.amount > 10</code>
45  	 * <p>
46  	 * Available context variables are:<br>
47  	 * <b>_this</b> -&gt; the validated bean<br>
48  	 * <b>_value</b> -&gt; the value to validate (e.g. the field value, parameter value, method return value,
49  	 *    or the validated bean for object level constraints)
50  	 */
51  	String when() default "";
52  }