Generate interface methods without "public" 80/45980/2
authorStephen Kitt <skitt@redhat.com>
Wed, 21 Sep 2016 14:21:26 +0000 (16:21 +0200)
committerTom Pantelis <tpanteli@brocade.com>
Thu, 22 Sep 2016 13:47:11 +0000 (13:47 +0000)
Method now tracks visibility explicitly; declarations have a blank
specifier, definitions have "public".

Change-Id: I6b1ce1c58d4f9f861e3117a6bf34aa5c9d6c5aa4
Signed-off-by: Stephen Kitt <skitt@redhat.com>
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/Method.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/MethodDeclaration.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/MethodDefinition.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/MethodSerializer.java

index be6b23e..425f85f 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
 
 import java.util.Collections;
 import java.util.List;
+import org.apache.commons.lang3.StringUtils;
 
 public class MethodDeclaration implements Method {
     private final String returnType;
@@ -44,6 +45,11 @@ public class MethodDeclaration implements Method {
         this.javadoc = javadoc;
     }
 
+    @Override
+    public String getVisibility() {
+        return StringUtils.EMPTY;
+    }
+
     @Override
     public String getReturnType() {
         return returnType;
index 9af011f..1d0e3a4 100644 (file)
@@ -9,8 +9,11 @@ package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
 
 import java.util.Collections;
 import java.util.List;
+import javax.lang.model.element.Modifier;
 
 public class MethodDefinition implements Method {
+    private static final String VISIBILITY_PUBLIC = Modifier.PUBLIC.toString();
+
     private final List<String> modifiers;
     private final String returnType;
     private final String name;
@@ -66,6 +69,11 @@ public class MethodDefinition implements Method {
         this.javadoc = javadoc;
     }
 
+    @Override
+    public String getVisibility() {
+        return VISIBILITY_PUBLIC;
+    }
+
     @Override
     public String getReturnType() {
         return returnType;
index eba6e53..4d727ae 100644 (file)
@@ -22,7 +22,8 @@ class MethodSerializer {
             build.append(a);
         }
 
-        build.append("    " + "public ");
+        build.append("    ");
+        build.append(method.getVisibility()).append(" ");
         for (String mod : method.getModifiers()) {
             build.append(mod).append(" ");
         }