Merge "BUG-1119: optimize length and range checks in generated sources."
[mdsal.git] / code-generator / binding-model-api / src / main / java / org / opendaylight / yangtools / sal / 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.yangtools.sal.binding.model.api.type.builder;
9
10 import java.util.List;
11 import org.opendaylight.yangtools.sal.binding.model.api.Constant;
12 import org.opendaylight.yangtools.sal.binding.model.api.Type;
13
14 public interface GeneratedTypeBuilderBase<T extends GeneratedTypeBuilderBase<T>> extends Type {
15
16     /**
17      * Adds new Enclosing Transfer Object into definition of Generated Type and
18      * returns <code>new</code> Instance of Generated TO Builder. <br>
19      * There is no need of specifying of Package Name because enclosing Type is
20      * already defined inside Generated Type with specific package name. <br>
21      * The name of enclosing Type cannot be same as Name of parent type and if
22      * there is already defined enclosing type with the same name, the new
23      * enclosing type will simply overwrite the older definition. <br>
24      * If the name of enclosing type is <code>null</code> the method SHOULD
25      * throw {@link IllegalArgumentException}
26      *
27      * @param name
28      *            Name of Enclosing Type
29      * @return <code>new</code> Instance of Generated Type Builder.
30      */
31     GeneratedTOBuilder addEnclosingTransferObject(final String name);
32
33     /**
34      * Adds new Enclosing Transfer Object <code>genTOBuilder</code> into
35      * definition of Generated Type
36      *
37      * <br>
38      * There is no need of specifying of Package Name because enclosing Type is
39      * already defined inside Generated Type with specific package name. <br>
40      * The name of enclosing Type cannot be same as Name of parent type and if
41      * there is already defined enclosing type with the same name, the new
42      * enclosing type will simply overwrite the older definition. <br>
43      * If the parameter <code>genTOBuilder</code> of enclosing type is
44      * <code>null</code> the method SHOULD throw
45      * {@link IllegalArgumentException}
46      *
47      * @param genTOBuilder
48      *            Name of Enclosing Type
49      */
50     T addEnclosingTransferObject(final GeneratedTOBuilder genTOBuilder);
51
52     /**
53      * Adds String definition of comment into Method Signature definition. <br>
54      * The comment String MUST NOT contain anny comment specific chars (i.e.
55      * "/**" or "//") just plain String text description.
56      *
57      * @param comment
58      *            Comment String.
59      */
60     T addComment(final String comment);
61
62     /**
63      * The method creates new AnnotationTypeBuilder containing specified package
64      * name an annotation name. <br>
65      * Neither the package name or annotation name can contain <code>null</code>
66      * references. In case that any of parameters contains <code>null</code> the
67      * method SHOULD thrown {@link IllegalArgumentException}
68      *
69      * @param packageName
70      *            Package Name of Annotation Type
71      * @param name
72      *            Name of Annotation Type
73      * @return <code>new</code> instance of Annotation Type Builder.
74      */
75     AnnotationTypeBuilder addAnnotation(final String packageName, final String name);
76
77     boolean isAbstract();
78
79     /**
80      * Sets the <code>abstract</code> flag to define Generated Type as
81      * <i>abstract</i> type.
82      *
83      * @param isAbstract
84      *            abstract flag
85      */
86     T setAbstract(boolean isAbstract);
87
88     List<Type> getImplementsTypes();
89
90     /**
91      * Add Type to implements.
92      *
93      * @param genType
94      *            Type to implement
95      * @return <code>true</code> if the addition of type is successful.
96      */
97     T addImplementsType(final Type genType);
98
99     /**
100      * Adds Constant definition and returns <code>new</code> Constant instance. <br>
101      * By definition Constant MUST be defined by return Type, Name and assigned
102      * value. The name SHOULD be defined with capital letters. Neither of method
103      * parameters can be <code>null</code> and the method SHOULD throw
104      * {@link IllegalArgumentException} if the contract is broken.
105      *
106      * @param type
107      *            Constant Type
108      * @param name
109      *            Name of Constant
110      * @param value
111      *            Assigned Value
112      * @return <code>new</code> Constant instance.
113      */
114     Constant addConstant(final Type type, final String name, final Object value);
115
116     /**
117      * Adds new Enumeration definition for Generated Type Builder and returns
118      * Enum Builder for specifying all Enum parameters. <br>
119      * If there is already Enumeration stored with the same name, the old enum
120      * will be simply overwritten byt new enum definition. <br>
121      * Name of Enumeration cannot be <code>null</code>, if it is
122      * <code>null</code> the method SHOULD throw
123      * {@link IllegalArgumentException}
124      *
125      * @param name
126      *            Enumeration Name
127      * @return <code>new</code> instance of Enumeration Builder.
128      */
129     EnumBuilder addEnumeration(final String name);
130
131     List<MethodSignatureBuilder> getMethodDefinitions();
132
133     /**
134      * Add new Method Signature definition for Generated Type Builder and
135      * returns Method Signature Builder for specifying all Method parameters. <br>
136      * Name of Method cannot be <code>null</code>, if it is <code>null</code>
137      * the method SHOULD throw {@link IllegalArgumentException} <br>
138      * By <i>Default</i> the MethodSignatureBuilder SHOULD be pre-set as
139      * {@link MethodSignatureBuilder#setAbstract(boolean)},
140      * {TypeMemberBuilder#setFinal(boolean)} and
141      * {TypeMemberBuilder#setAccessModifier(boolean)}
142      *
143      * @param name
144      *            Name of Method
145      * @return <code>new</code> instance of Method Signature Builder.
146      */
147     MethodSignatureBuilder addMethod(final String name);
148
149     /**
150      * Checks if GeneratedTypeBuilder contains method with name
151      * <code>methodName</code>
152      *
153      * @param methodName
154      *            is method name
155      */
156     boolean containsMethod(final String methodName);
157
158     List<GeneratedPropertyBuilder> getProperties();
159
160     /**
161      * Add new Generated Property definition for Generated Transfer Object
162      * Builder and returns Generated Property Builder for specifying Property. <br>
163      * Name of Property cannot be <code>null</code>, if it is <code>null</code>
164      * the method SHOULD throw {@link IllegalArgumentException}
165      *
166      * @param name
167      *            Name of Property
168      * @return <code>new</code> instance of Generated Property Builder.
169      */
170     GeneratedPropertyBuilder addProperty(final String name);
171
172     /**
173      * Check whether GeneratedTOBuilder contains property with name
174      * <code>name</code>
175      *
176      * @param name
177      *            of property which existance is checked
178      * @return true if property <code>name</code> exists in list of properties.
179      */
180     boolean containsProperty(final String name);
181
182 }