2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster.datastore.node.utils.stream;
11 import java.io.IOException;
12 import java.io.ObjectInputStream;
13 import java.io.ObjectOutputStream;
14 import java.io.Serializable;
15 import java.net.URISyntaxException;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
18 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
20 public class SampleNormalizedNodeSerializable implements Serializable {
21 private static final long serialVersionUID = 1L;
23 private NormalizedNode<?, ?> input;
25 public SampleNormalizedNodeSerializable(NormalizedNode<?, ?> input) {
29 public NormalizedNode<?, ?> getInput() {
33 private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException, URISyntaxException {
34 NormalizedNodeDataInput reader = new NormalizedNodeInputStreamReader(stream);
35 this.input = reader.readNormalizedNode();
38 private void writeObject(final ObjectOutputStream stream) throws IOException {
39 NormalizedNodeStreamWriter writer = new NormalizedNodeOutputStreamWriter(stream);
40 NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(writer);
42 normalizedNodeWriter.write(this.input);