Use Map.of() instead of Collections.emptyMap() in builders
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / main / java / org / opendaylight / mdsal / binding / java / api / generator / AbstractBuilderTemplate.xtend
index fd34bf5cb5d98d9777e93dd28782797fc70a21b8..c558ada0f59c4c26259c2b8aa8b011da715b36da 100644 (file)
@@ -7,13 +7,8 @@
  */
 package org.opendaylight.mdsal.binding.java.api.generator
 
-import static org.opendaylight.mdsal.binding.model.util.Types.STRING;
-import static org.opendaylight.mdsal.binding.spec.naming.BindingMapping.AUGMENTATION_FIELD
-
-import com.google.common.base.MoreObjects
 import java.util.ArrayList
 import java.util.Collection
-import java.util.Collections
 import java.util.Comparator
 import java.util.List
 import java.util.Set
@@ -22,7 +17,7 @@ import org.opendaylight.mdsal.binding.model.api.GeneratedProperty
 import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject
 import org.opendaylight.mdsal.binding.model.api.GeneratedType
 import org.opendaylight.mdsal.binding.model.api.Type
-import org.opendaylight.mdsal.binding.model.util.BindingTypes
+import org.opendaylight.mdsal.binding.model.ri.BindingTypes
 import org.opendaylight.mdsal.binding.spec.naming.BindingMapping
 
 abstract class AbstractBuilderTemplate extends BaseTemplate {
@@ -81,29 +76,6 @@ abstract class AbstractBuilderTemplate extends BaseTemplate {
         «ENDIF»
     '''
 
-    def protected final generateAugmentField() {
-        val augmentTypeRef = augmentType.importedName
-        return '''
-           «JU_MAP.importedName»<«CLASS.importedName»<? extends «augmentTypeRef»>, «augmentTypeRef»> «AUGMENTATION_FIELD» = «Collections.importedName».emptyMap();
-        '''
-    }
-
-    override generateToString(Collection<? extends GeneratedProperty> properties) '''
-        «IF properties !== null»
-            @«OVERRIDE.importedName»
-            public «STRING.importedName» toString() {
-                final «MoreObjects.importedName».ToStringHelper helper = «MoreObjects.importedName».toStringHelper("«targetType.name»");
-                «FOR property : properties»
-                    «CODEHELPERS.importedName».appendValue(helper, "«property.fieldName»", «property.fieldName»);
-                «ENDFOR»
-                «IF augmentType !== null»
-                    «CODEHELPERS.importedName».appendValue(helper, "«AUGMENTATION_FIELD»", augmentations().values());
-                «ENDIF»
-                return helper.toString();
-            }
-        «ENDIF»
-    '''
-
     /**
      * Template method which generate getter methods for IMPL class.
      *
@@ -190,4 +162,12 @@ abstract class AbstractBuilderTemplate extends BaseTemplate {
         }
         return null
     }
+
+    package static def hasNonDefaultMethods(GeneratedType type) {
+        !type.methodDefinitions.isEmpty && type.methodDefinitions.exists([def | !def.isDefault])
+    }
+
+    package static def nonDefaultMethods(GeneratedType type) {
+        type.methodDefinitions.filter([def | !def.isDefault])
+    }
 }