Binding V2 generator - fix choice/case
[mdsal.git] / binding2 / mdsal-binding2-generator-api / src / main / java / org / opendaylight / mdsal / binding / javav2 / model / api / type / builder / GeneratedTypeBuilderBase.java
1 /*
2  * Copyright (c) 2017 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.mdsal.binding.javav2.model.api.type.builder;
10
11 import com.google.common.annotations.Beta;
12 import java.util.List;
13 import java.util.Optional;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.mdsal.binding.javav2.generator.context.ModuleContext;
16 import org.opendaylight.mdsal.binding.javav2.model.api.Constant;
17 import org.opendaylight.mdsal.binding.javav2.model.api.Type;
18 import org.opendaylight.mdsal.binding.javav2.model.api.TypeComment;
19 import org.opendaylight.mdsal.binding.javav2.model.api.YangSourceDefinition;
20 import org.opendaylight.yangtools.yang.common.QName;
21
22 @Beta
23 public interface GeneratedTypeBuilderBase<T extends GeneratedTypeBuilderBase<T>> extends Type {
24
25     /**
26      * Adds new Enclosing Transfer Object into definition of Generated Type and
27      * returns <code>new</code> Instance of Generated TO Builder. <br>
28      * There is no need of specifying of Package Name because enclosing Type is
29      * already defined inside Generated Type with specific package name. <br>
30      * The name of enclosing Type cannot be same as Name of parent type and if
31      * there is already defined enclosing type with the same name, the new
32      * enclosing type will simply overwrite the older definition. <br>
33      * If the name of enclosing type is <code>null</code> the method SHOULD
34      * throw {@link IllegalArgumentException}
35      *
36      * @param name
37      *            Name of Enclosing Type
38      * @return <code>new</code> Instance of Generated Type Builder.
39      */
40     GeneratedTOBuilder addEnclosingTransferObject(String name);
41
42     /**
43      * Adds new Enclosing Transfer Object <code>genTOBuilder</code> into
44      * definition of Generated Type
45      *
46      * <br>
47      * There is no need of specifying of Package Name because enclosing Type is
48      * already defined inside Generated Type with specific package name. <br>
49      * The name of enclosing Type cannot be same as Name of parent type and if
50      * there is already defined enclosing type with the same name, the new
51      * enclosing type will simply overwrite the older definition. <br>
52      * If the parameter <code>genTOBuilder</code> of enclosing type is
53      * <code>null</code> the method SHOULD throw
54      * {@link IllegalArgumentException}
55      *
56      * @param genTOBuilder
57      *            Name of Enclosing Type
58      */
59     T addEnclosingTransferObject(GeneratedTOBuilder genTOBuilder);
60
61     /**
62      * Adds String definition of comment into Method Signature definition. <br>
63      * The comment String MUST NOT contain anny comment specific chars (i.e.
64      * "/**" or "//") just plain String text description.
65      *
66      * @param comment
67      *            Comment String.
68      */
69     T addComment(TypeComment comment);
70
71     /**
72      * The method creates new AnnotationTypeBuilder containing specified package
73      * name an annotation name. <br>
74      * Neither the package name or annotation name can contain <code>null</code>
75      * references. In case that any of parameters contains <code>null</code> the
76      * method SHOULD thrown {@link IllegalArgumentException}
77      *
78      * @param packageName
79      *            Package Name of Annotation Type
80      * @param name
81      *            Name of Annotation Type
82      * @return <code>new</code> instance of Annotation Type Builder.
83      */
84     AnnotationTypeBuilder addAnnotation(String packageName, String name);
85
86     boolean isAbstract();
87
88     /**
89      * Sets the <code>abstract</code> flag to define Generated Type as
90      * <i>abstract</i> type.
91      *
92      * @param isAbstract
93      *            abstract flag
94      */
95     T setAbstract(boolean isAbstract);
96
97     List<Type> getImplementsTypes();
98
99     /**
100      * Add Type to implements.
101      *
102      * @param genType
103      *            Type to implement
104      * @return <code>true</code> if the addition of type is successful.
105      */
106     T addImplementsType(Type genType);
107
108     /**
109      * Adds Constant definition and returns <code>new</code> Constant instance. <br>
110      * By definition Constant MUST be defined by return Type, Name and assigned
111      * value. The name SHOULD be defined with capital letters. Neither of method
112      * parameters can be <code>null</code> and the method SHOULD throw
113      * {@link IllegalArgumentException} if the contract is broken.
114      *
115      * @param type
116      *            Constant Type
117      * @param name
118      *            Name of Constant
119      * @param value
120      *            Assigned Value
121      * @return <code>new</code> Constant instance.
122      */
123     Constant addConstant(Type type, String name, Object value);
124
125     /**
126      * Adds new Enumeration definition for Generated Type Builder and returns
127      * Enum Builder for specifying all Enum parameters. <br>
128      * If there is already Enumeration stored with the same name, the old enum
129      * will be simply overwritten byt new enum definition. <br>
130      * Name of Enumeration cannot be <code>null</code>, if it is
131      * <code>null</code> the method SHOULD throw
132      * {@link IllegalArgumentException}
133      *
134      * @param name
135      *            Enumeration Name
136      * @return <code>new</code> instance of Enumeration Builder.
137      */
138     EnumBuilder addEnumeration(String name, ModuleContext context);
139
140     /**
141      * Gets parent type for data schema node builder, the parent
142      * MUST be a data tree node.
143      *
144      * @return parent generated type of tree node
145      */
146     Type getParentTypeForBuilder();
147
148     /**
149      * Sets parent type for data schema node builder, the parent
150      * MUST be a data tree node.
151      *
152      * @param type parent generated type of tree node
153      * @return parent generated type
154      */
155     Type setParentTypeForBuilder(Type type);
156
157     List<MethodSignatureBuilder> getMethodDefinitions();
158
159     /**
160      * Add new Method Signature definition for Generated Type Builder and
161      * returns Method Signature Builder for specifying all Method parameters. <br>
162      * Name of Method cannot be <code>null</code>, if it is <code>null</code>
163      * the method SHOULD throw {@link IllegalArgumentException} <br>
164      * By <i>Default</i> the MethodSignatureBuilder SHOULD be pre-set as
165      * {@link MethodSignatureBuilder#setAbstract(boolean)},
166      * {TypeMemberBuilder#setFinal(boolean)} and
167      * {TypeMemberBuilder#setAccessModifier(boolean)}
168      *
169      * @param name
170      *            Name of Method
171      * @return <code>new</code> instance of Method Signature Builder.
172      */
173     MethodSignatureBuilder addMethod(String name);
174
175     /**
176      * Checks if GeneratedTypeBuilder contains method with name
177      * <code>methodName</code>
178      *
179      * @param methodName
180      *            is method name
181      */
182     boolean containsMethod(String methodName);
183
184     List<GeneratedPropertyBuilder> getProperties();
185
186     /**
187      * Returns the YANG definition of this type, if available.
188      *
189      * @return YANG source definition, or empty when unavailable.
190      */
191     Optional<YangSourceDefinition> getYangSourceDefinition();
192
193     /**
194      * Add new Generated Property definition for Generated Transfer Object
195      * Builder and returns Generated Property Builder for specifying Property. <br>
196      * Name of Property cannot be <code>null</code>, if it is <code>null</code>
197      * the method SHOULD throw {@link IllegalArgumentException}
198      *
199      * @param name
200      *            Name of Property
201      * @return <code>new</code> instance of Generated Property Builder.
202      */
203     GeneratedPropertyBuilder addProperty(String name);
204
205     /**
206      * Check whether GeneratedTOBuilder contains property with name
207      * <code>name</code>
208      *
209      * @param name
210      *            of property which existance is checked
211      * @return true if property <code>name</code> exists in list of properties.
212      */
213     boolean containsProperty(String name);
214
215     /**
216      * Set a string that contains a human-readable textual description of type
217      * definition.
218      *
219      * @param description
220      *            a string that contains a human-readable textual description of
221      *            type definition.
222      */
223     void setDescription(String description);
224
225     /**
226      * Set the name of the module, in which generated type was specified.
227      *
228      * @param moduleName
229      *            the name of the module
230      */
231     void setModuleName(String moduleName);
232
233     /**
234      * Set a list of QNames which represent schema path in schema tree from
235      * actual concrete type to the root.
236      *
237      * @param schemaPath
238      *            a list of QNames which represent schema path in schema tree
239      */
240     void setSchemaPath(List<QName> schemaPath);
241
242     /**
243      * Set a string that is used to specify a textual cross-reference to an
244      * external document, either another module that defines related management
245      * information, or a document that provides additional information relevant
246      * to this definition.
247      *
248      * @param reference
249      *            a textual cross-reference to an external document.
250      */
251     void setReference(String reference);
252
253     /**
254      * Set the YANG source definition.
255      *
256      * @param definition YANG source definition, must not be null
257      */
258     void setYangSourceDefinition(@NonNull YangSourceDefinition definition);
259 }