import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputStreamReader;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
}
public static DataTreeCandidate readDataTreeCandidate(final DataInput in) throws IOException {
- final NormalizedNodeDataInput reader = new NormalizedNodeInputStreamReader(in);
+ final NormalizedNodeDataInput reader = NormalizedNodeInputOutput.newDataInput(in);
final YangInstanceIdentifier rootPath = reader.readYangInstanceIdentifier();
final byte type = reader.readByte();
final DataTreeCandidateNode rootNode;
switch (type) {
+ case APPEARED:
+ rootNode = ModifiedDataTreeCandidateNode.create(ModificationType.APPEARED, readChildren(reader));
+ break;
case DELETE:
rootNode = DeletedDataTreeCandidateNode.create();
break;
+ case DISAPPEARED:
+ rootNode = ModifiedDataTreeCandidateNode.create(ModificationType.DISAPPEARED, readChildren(reader));
+ break;
case SUBTREE_MODIFIED:
- rootNode = ModifiedDataTreeCandidateNode.create(readChildren(reader));
+ rootNode = ModifiedDataTreeCandidateNode.create(ModificationType.SUBTREE_MODIFIED,
+ readChildren(reader));
break;
case WRITE:
rootNode = DataTreeCandidateNodes.fromNormalizedNode(reader.readNormalizedNode());
break;
+ case UNMODIFIED:
+ rootNode = AbstractDataTreeCandidateNode.createUnmodified();
+ break;
default:
throw new IllegalArgumentException("Unhandled node type " + type);
}
out.writeByte(UNMODIFIED);
break;
default:
- throw new IllegalArgumentException("Unhandled node type " + node.getModificationType());
+ throwUnhandledNodeType(node);
}
}
public static void writeDataTreeCandidate(final DataOutput out, DataTreeCandidate candidate) throws IOException {
- try (final NormalizedNodeDataOutput writer = NormalizedNodeInputOutput.newDataOutput(out)) {
+ try (NormalizedNodeDataOutput writer = NormalizedNodeInputOutput.newDataOutput(out)) {
writer.writeYangInstanceIdentifier(candidate.getRootPath());
final DataTreeCandidateNode node = candidate.getRootNode();
writer.writeNormalizedNode(node.getDataAfter().get());
break;
default:
- throw new IllegalArgumentException("Unhandled node type " + node.getModificationType());
+ throwUnhandledNodeType(node);
}
}
}
+
+ private static void throwUnhandledNodeType(final DataTreeCandidateNode node) {
+ throw new IllegalArgumentException("Unhandled node type " + node.getModificationType());
+ }
}