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