01 /*
02 * Optional.java
03 *
04 * Copyright (c) 2008, The University of Sheffield.
05 *
06 * This file is part of GATE (see http://gate.ac.uk/), and is free
07 * software, licenced under the GNU Library General Public License,
08 * Version 2, June 1991 (in the distribution as file licence.html,
09 * and also available at http://gate.ac.uk/gate/licence.html).
10 *
11 * Ian Roberts, 27/Jul/2008
12 *
13 * $Id: Optional.java 9845 2008-08-25 22:23:24Z ian_roberts $
14 */
15
16 package gate.creole.metadata;
17
18 import java.lang.annotation.Documented;
19 import java.lang.annotation.ElementType;
20 import java.lang.annotation.Retention;
21 import java.lang.annotation.RetentionPolicy;
22 import java.lang.annotation.Target;
23
24 /**
25 * Marker annotation used in conjunction with {@link CreoleParameter} to mark
26 * parameters that are optional.
27 *
28 * <pre>
29 * @Optional
30 * @CreoleParameter
31 * public void setAnnotationTypes(List<String> types) { ... }
32 * </pre>
33 *
34 * While usually used to mark parameters as optional, this annotation
35 * also supports an optional boolean flag, so it can be used as
36 * <code>@Optional(false)</code> to mark required parameters. This is not
37 * generally necessary, as parameters are required by default, however if a
38 * given parameter has been annotated as <code>@Optional</code> in a superclass
39 * this will be inherited. If you want to change the parameter to be required
40 * in a subclass then you must use <code>@Optional(false)</code>.
41 */
42 @Documented
43 @Target( {ElementType.METHOD})
44 @Retention(RetentionPolicy.RUNTIME)
45 public @interface Optional {
46 /**
47 * Defaults to true but can be set to false to explicitly mark a parameter as
48 * required rather than optional.
49 */
50 boolean value() default true;
51 }
|