Generate javadoc for builder setters
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / main / java / org / opendaylight / mdsal / binding / java / api / generator / BuilderTemplate.xtend
index 2a23fe1a90a776e0d971fc4137cfdac66c99b50d..c29f8aea4b59143f86d0be305e52a3f712545974 100644 (file)
@@ -70,7 +70,9 @@ class BuilderTemplate extends AbstractBuilderTemplate {
             «constantsDeclarations()»
 
             «IF augmentType !== null»
-                «generateAugmentField()»
+                «val augmentTypeRef = augmentType.importedName»
+                «val mapTypeRef = JU_MAP.importedName»
+                «mapTypeRef»<«CLASS.importedName»<? extends «augmentTypeRef»>, «augmentTypeRef»> «AUGMENTATION_FIELD» = «mapTypeRef».of();
             «ENDIF»
 
             /**
@@ -105,7 +107,7 @@ class BuilderTemplate extends AbstractBuilderTemplate {
              *
              * @return A new {@link «targetTypeName»} instance.
              */
-            public «targetTypeName» build() {
+            public «targetType.importedNonNull» build() {
                 return new «type.enclosedTypes.get(0).importedName»(this);
             }
 
@@ -357,7 +359,7 @@ class BuilderTemplate extends AbstractBuilderTemplate {
         «ENDFOR»
     '''
 
-    def private generateSetter(GeneratedProperty field) {
+    def private generateSetter(BuilderGeneratedProperty field) {
         val returnType = field.returnType
         if (returnType instanceof ParameterizedType) {
             if (Types.isListType(returnType) || Types.isSetType(returnType)) {
@@ -373,11 +375,19 @@ class BuilderTemplate extends AbstractBuilderTemplate {
         return generateSimpleSetter(field, returnType)
     }
 
-    def private generateListSetter(GeneratedProperty field, Type actualType) '''
+    def private generateListSetter(BuilderGeneratedProperty field, Type actualType) '''
         «val restrictions = restrictionsForSetter(actualType)»
         «IF restrictions !== null»
             «generateCheckers(field, restrictions, actualType)»
         «ENDIF»
+
+        /**
+         * Set the property corresponding to {@link «targetType.importedName»#«field.getterName»()} to the specified
+         * value.
+         *
+         * @param values desired value
+         * @return this builder
+         */
         public «type.getName» set«field.getName.toFirstUpper»(final «field.returnType.importedName» values) {
         «IF restrictions !== null»
             if (values != null) {
@@ -392,11 +402,19 @@ class BuilderTemplate extends AbstractBuilderTemplate {
 
     '''
 
-    def private generateMapSetter(GeneratedProperty field, Type actualType) '''
+    def private generateMapSetter(BuilderGeneratedProperty field, Type actualType) '''
         «val restrictions = restrictionsForSetter(actualType)»
         «IF restrictions !== null»
             «generateCheckers(field, restrictions, actualType)»
         «ENDIF»
+
+        /**
+         * Set the property corresponding to {@link «targetType.importedName»#«field.getterName»()} to the specified
+         * value.
+         *
+         * @param values desired value
+         * @return this builder
+         */
         public «type.getName» set«field.name.toFirstUpper»(final «field.returnType.importedName» values) {
         «IF restrictions !== null»
             if (values != null) {
@@ -410,13 +428,20 @@ class BuilderTemplate extends AbstractBuilderTemplate {
         }
     '''
 
-    def private generateSimpleSetter(GeneratedProperty field, Type actualType) '''
+    def private generateSimpleSetter(BuilderGeneratedProperty field, Type actualType) '''
         «val restrictions = restrictionsForSetter(actualType)»
         «IF restrictions !== null»
 
             «generateCheckers(field, restrictions, actualType)»
         «ENDIF»
 
+        /**
+         * Set the property corresponding to {@link «targetType.importedName»#«field.getterName»()} to the specified
+         * value.
+         *
+         * @param value desired value
+         * @return this builder
+         */
         «val setterName = "set" + field.getName.toFirstUpper»
         public «type.getName» «setterName»(final «field.returnType.importedName» value) {
             «IF restrictions !== null»
@@ -447,7 +472,6 @@ class BuilderTemplate extends AbstractBuilderTemplate {
 
         «IF augmentType !== null»
             «val augmentTypeRef = augmentType.importedName»
-            «val jlClassRef = CLASS.importedName»
             «val hashMapRef = JU_HASHMAP.importedName»
             /**
               * Add an augmentation to this builder's product.
@@ -457,12 +481,11 @@ class BuilderTemplate extends AbstractBuilderTemplate {
               * @throws NullPointerException if {@code augmentation} is null
               */
             public «type.name» addAugmentation(«augmentTypeRef» augmentation) {
-                «jlClassRef»<? extends «augmentTypeRef»> augmentationType = augmentation.«DATA_CONTAINER_IMPLEMENTED_INTERFACE_NAME»();
                 if (!(this.«AUGMENTATION_FIELD» instanceof «hashMapRef»)) {
                     this.«AUGMENTATION_FIELD» = new «hashMapRef»<>();
                 }
 
-                this.«AUGMENTATION_FIELD».put(augmentationType, augmentation);
+                this.«AUGMENTATION_FIELD».put(augmentation.«DATA_CONTAINER_IMPLEMENTED_INTERFACE_NAME»(), augmentation);
                 return this;
             }
 
@@ -473,7 +496,7 @@ class BuilderTemplate extends AbstractBuilderTemplate {
               * @param augmentationType augmentation type to be removed
               * @return this builder
               */
-            public «type.name» removeAugmentation(«jlClassRef»<? extends «augmentTypeRef»> augmentationType) {
+            public «type.name» removeAugmentation(«CLASS.importedName»<? extends «augmentTypeRef»> augmentationType) {
                 if (this.«AUGMENTATION_FIELD» instanceof «hashMapRef») {
                     this.«AUGMENTATION_FIELD».remove(augmentationType);
                 }
@@ -534,6 +557,14 @@ class BuilderTemplate extends AbstractBuilderTemplate {
     }
 
     private def generateAugmentation() '''
+        /**
+         * Return the specified augmentation, if it is present in this builder.
+         *
+         * @param <E$$> augmentation type
+         * @param augmentationType augmentation type class
+         * @return Augmentation object from this builder, or {@code null} if not present
+         * @throws «NPE.importedName» if {@code augmentType} is {@code null}
+         */
         @«SUPPRESS_WARNINGS.importedName»({ "unchecked", "checkstyle:methodTypeParameterName"})
         public <E$$ extends «augmentType.importedName»> E$$ «AUGMENTABLE_AUGMENTATION_NAME»(«CLASS.importedName»<E$$> augmentationType) {
             return (E$$) «AUGMENTATION_FIELD».get(«JU_OBJECTS.importedName».requireNonNull(augmentationType));