View Javadoc
1   package ca.uhn.fhir.model.api.annotation;
2   
3   /*
4    * #%L
5    * HAPI FHIR - Core Library
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import java.lang.annotation.ElementType;
24  import java.lang.annotation.Retention;
25  import java.lang.annotation.RetentionPolicy;
26  import java.lang.annotation.Target;
27  
28  import ca.uhn.fhir.model.api.IElement;
29  
30  /**
31   * Field annotation for fields within resource and datatype definitions, indicating 
32   * a child of that type.
33   */
34  @Retention(RetentionPolicy.RUNTIME)
35  @Target(value= {ElementType.FIELD})
36  public @interface Child {
37  
38  	/**
39  	 * Constant value to supply for {@link #order()} when the order is defined
40  	 * elsewhere
41  	 */
42  	int ORDER_UNKNOWN = -1;
43  	
44  	/**
45  	 * Constant value to supply for {@link #max()} to indicate '*' (no maximum)
46  	 */
47  	int MAX_UNLIMITED = -1;
48  
49  	/**
50  	 * Constant value to supply for {@link #order()} to indicate that this child should replace the
51  	 * entry in the superclass with the same name (and take its {@link Child#order() order} value 
52  	 * in the process). This is useful if you wish to redefine an existing field in a resource/type
53  	 * definition in order to constrain/extend it.
54  	 */
55  	int REPLACE_PARENT = -2;
56  
57  	/**
58  	 * The name of this field, as it will appear in serialized versions of the message
59  	 */
60  	String name();
61  	
62  	/**
63  	 * The order in which this field comes within its parent. The first field should have a 
64  	 * value of 0, the second a value of 1, etc.
65  	 */
66  	int order() default ORDER_UNKNOWN;
67  
68  	/**
69  	 * The minimum number of repetitions allowed for this child
70  	 */
71  	int min() default 0;
72  
73  	/**
74  	 * The maximum number of repetitions allowed for this child. Should be
75  	 * set to {@link #MAX_UNLIMITED} if there is no limit to the number of
76  	 * repetitions.
77  	 */
78  	int max() default 1;
79  
80  	/**
81  	 * Lists the allowable types for this field, if the field supports multiple
82  	 * types (otherwise does not need to be populated).
83  	 * <p>
84  	 * For example, if this field supports either DateTimeDt or BooleanDt types,
85  	 * those two classes should be supplied here.
86  	 * </p>
87  	 */
88  	Class<? extends IElement>[] type() default {};
89  
90  	// Not implemented
91  //	/**
92  //	 * This value is used when extending a built-in model class and defining a
93  //	 * field to replace a field within the built-in class. For example, the {@link Patient} 
94  //	 * resource has a {@link Patient#getName() name} field, but if you wanted to extend Patient and
95  //	 * provide your own implementation of {@link HumanNameDt} (most likely your own subclass of 
96  //	 * HumanNameDt which adds extensions of your choosing) you could do that using a replacement field. 
97  //	 */
98  //	String replaces() default "";
99  
100 	/**
101 	 * Is this element a modifier?
102 	 */
103 	boolean modifier() default false;	
104 
105 	/**
106 	 * Should this element be included in the summary view
107 	 */
108 	boolean summary() default false;
109 	
110 }