X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2Fserialization%2FValueSerializer.java;h=bb7f9c35eead01ba942327486d0f0306913aaac7;hp=6a843f57c7718fb76911e90649b7194e3b6db0bb;hb=b17a51ecb983331f0e521e40f9dd2474f268de13;hpb=531621aac4cff9d39cbd8668a53bdeba8a0e6d81 diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializer.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializer.java index 6a843f57c7..bb7f9c35ee 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializer.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/serialization/ValueSerializer.java @@ -8,6 +8,7 @@ package org.opendaylight.controller.cluster.datastore.node.utils.serialization; +import com.google.protobuf.ByteString; import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory; import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils; import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; @@ -27,17 +28,19 @@ public class ValueSerializer { builder.setInstanceIdentifierValue( InstanceIdentifierUtils.toSerializable((YangInstanceIdentifier) value, context)); } else if(value instanceof Set) { - Set set = (Set) value; - if(!set.isEmpty()){ - for(Object o : set){ - if(o instanceof String){ + Set set = (Set) value; + if (!set.isEmpty()) { + for (Object o : set) { + if (o instanceof String) { builder.addBitsValue(o.toString()); } else { throw new IllegalArgumentException("Expected value type to be Bits but was : " + - value.toString()); + value.toString()); } } } + } else if(value instanceof byte[]){ + builder.setBytesValue(ByteString.copyFrom((byte[]) value)); } else { builder.setValue(value.toString()); } @@ -56,7 +59,9 @@ public class ValueSerializer { return InstanceIdentifierUtils.fromSerializable( node.getInstanceIdentifierValue(), context); } else if(node.getIntValueType() == ValueType.BITS_TYPE.ordinal()){ - return new HashSet(node.getBitsValueList()); + return new HashSet<>(node.getBitsValueList()); + } else if(node.getIntValueType() == ValueType.BINARY_TYPE.ordinal()){ + return node.getBytesValue().toByteArray(); } return deSerializeBasicTypes(node.getIntValueType(), node.getValue()); }