BUG-2453 (De)Serialize enum values as defined in yang
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / mapping / rpc / ModuleRpcs.java
index a081890d398c1c8fd2f349b8e5127b83e5a57cbf..7316dbcb06e7d083ee3d271039ebfb02a3091ace 100644 (file)
@@ -10,19 +10,24 @@ package org.opendaylight.controller.netconf.confignetconfconnector.mapping.rpc;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Maps;
+import java.util.Map;
 import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry;
 import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry.Rpc;
-
-import java.util.Map;
+import org.opendaylight.controller.netconf.confignetconfconnector.osgi.EnumResolver;
 
 public final class ModuleRpcs {
 
-    Map<String, String> yangToJavaNames = Maps.newHashMap();
-    Map<String, Map<String, InstanceRuntimeRpc>> rpcMapping = Maps.newHashMap();
+    private final Map<String, String> yangToJavaNames = Maps.newHashMap();
+    private final Map<String, Map<String, InstanceRuntimeRpc>> rpcMapping = Maps.newHashMap();
+    private final EnumResolver enumResolver;
+
+    public ModuleRpcs(final EnumResolver enumResolver) {
+        this.enumResolver = enumResolver;
+    }
 
     public void addNameMapping(RuntimeBeanEntry runtimeEntry) {
         String yangName = runtimeEntry.getYangName();
-        Preconditions.checkState(yangToJavaNames.containsKey(yangName) == false,
+        Preconditions.checkState(!yangToJavaNames.containsKey(yangName),
                 "RuntimeBean %s found twice in same namespace", yangName);
         yangToJavaNames.put(yangName, runtimeEntry.getJavaNamePrefix());
     }
@@ -35,9 +40,9 @@ public final class ModuleRpcs {
             rpcMapping.put(yangName, map);
         }
 
-        Preconditions.checkState(map.containsKey(rpc.getYangName()) == false, "Rpc %s for runtime bean %s added twice",
+        Preconditions.checkState(!map.containsKey(rpc.getYangName()), "Rpc %s for runtime bean %s added twice",
                 rpc.getYangName(), yangName);
-        map.put(rpc.getYangName(), new InstanceRuntimeRpc(rpc));
+        map.put(rpc.getYangName(), new InstanceRuntimeRpc(rpc, enumResolver));
     }
 
     public String getRbeJavaName(String yangName) {
@@ -55,4 +60,5 @@ public final class ModuleRpcs {
         Preconditions.checkState(rpc != null, "No rpc found for runtime bean %s with name %s", rbeName, rpcName);
         return rpc;
     }
+
 }