Home | History | Annotate | Download | only in annotations
      1 package org.testng.annotations;
      2 
      3 import static java.lang.annotation.ElementType.PARAMETER;
      4 import static java.lang.annotation.RetentionPolicy.RUNTIME;
      5 
      6 import org.testng.internal.Parameters;
      7 
      8 import java.lang.annotation.Retention;
      9 import java.lang.annotation.Target;
     10 
     11 /**
     12  * Specifies that the current parameter is optional.  TestNG will pass
     13  * in a specified default value, or <code>null</code> if none is specified.
     14  */
     15 @Retention(RUNTIME)
     16 @Target({PARAMETER})
     17 public @interface Optional {
     18   /** The default value to pass to this parameter.  <p>The default deserves
     19    * a bit of explanation.  JSR-175 (which defines annotations) says that
     20    * Java annotation parameters can only be ConstantExpressions, which
     21    * can be primitive/string literals, but not <code>null</code>.</p>
     22    * <p>In this case, we use this string as a substitute
     23    * for <code>null</code>; in practice, TestNG will pass <code>null</code>
     24    * to your code, and not the string "null", if you do not specify
     25    * a default value here in this parameter.
     26    */
     27   public String value() default Parameters.NULL_VALUE;
     28 }
     29