Use NormalizedNode streaming serialization in sal-remoterpc-connector
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / NormalizedNodeToNodeCodec.java
index 6669e48627b6b782327684fcc9a13818b867816a..8ca0e76b014961fed6232839570cc23b71c97ee1 100644 (file)
@@ -1,11 +1,9 @@
 /*
+ * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
  *
- *  Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- *  This program and the accompanying materials are made available under the
- *  terms of the Eclipse Public License v1.0 which accompanies this distribution,
- *  and is available at http://www.eclipse.org/legal/epl-v10.html
- *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
 package org.opendaylight.controller.cluster.datastore.node;
@@ -18,7 +16,6 @@ import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessa
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public class NormalizedNodeToNodeCodec {
     public interface Encoded {
@@ -33,13 +30,10 @@ public class NormalizedNodeToNodeCodec {
         YangInstanceIdentifier getDecodedPath();
     }
 
-    private final SchemaContext ctx;
-
-    public NormalizedNodeToNodeCodec(final SchemaContext ctx){
-        this.ctx = ctx;
+    public NormalizedNodeToNodeCodec() {
     }
 
-    public NormalizedNodeMessages.Container encode(NormalizedNode<?,?> node){
+    public NormalizedNodeMessages.Container encode(NormalizedNode<?,?> node) {
         return encode(null, node).getEncodedNode();
     }
 
@@ -52,8 +46,8 @@ public class NormalizedNodeToNodeCodec {
         // Note: parent path is no longer used
         builder.setParentPath("");
 
-        if(node != null) {
-            if(path == null) {
+        if (node != null) {
+            if (path == null) {
                 builder.setNormalizedNode(NormalizedNodeSerializer.serialize(node));
             } else {
                 Serializer serializer = NormalizedNodeSerializer.newSerializer(node);
@@ -66,13 +60,13 @@ public class NormalizedNodeToNodeCodec {
     }
 
 
-    public NormalizedNode<?,?> decode(NormalizedNodeMessages.Node node){
+    public NormalizedNode<?,?> decode(NormalizedNodeMessages.Node node) {
         return decode(null, node).getDecodedNode();
     }
 
     public Decoded decode(NormalizedNodeMessages.InstanceIdentifier path,
             NormalizedNodeMessages.Node node) {
-        if(node.getIntType() < 0 || node.getSerializedSize() == 0){
+        if (node.getIntType() < 0 || node.getSerializedSize() == 0) {
             return new DecodedImpl(null, null);
         }
 
@@ -86,7 +80,7 @@ public class NormalizedNodeToNodeCodec {
         private final NormalizedNode<?, ?> decodedNode;
         private final YangInstanceIdentifier decodedPath;
 
-        public DecodedImpl(NormalizedNode<?, ?> decodedNode, YangInstanceIdentifier decodedPath) {
+        DecodedImpl(NormalizedNode<?, ?> decodedNode, YangInstanceIdentifier decodedPath) {
             this.decodedNode = decodedNode;
             this.decodedPath = decodedPath;
         }