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