Merge "BUG 2221 : Add metering to ShardTransaction actor"
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / test / java / org / opendaylight / controller / cluster / datastore / node / utils / stream / SampleNormalizedNodeSerializable.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.cluster.datastore.node.utils.stream;
10
11
12 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
13
14 import java.io.IOException;
15 import java.io.ObjectInputStream;
16 import java.io.ObjectOutputStream;
17 import java.io.Serializable;
18 import java.net.URISyntaxException;
19
20 public class SampleNormalizedNodeSerializable implements Serializable {
21
22     private NormalizedNode<?, ?> input;
23
24     public SampleNormalizedNodeSerializable(NormalizedNode<?, ?> input) {
25         this.input = input;
26     }
27
28     public NormalizedNode<?, ?> getInput() {
29         return input;
30     }
31
32     private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException, URISyntaxException {
33         NormalizedNodeStreamReader reader = new NormalizedNodeInputStreamReader(stream);
34         this.input = reader.readNormalizedNode();
35     }
36
37     private void writeObject(final ObjectOutputStream stream) throws IOException {
38         NormalizedNodeStreamWriter writer = new NormalizedNodeOutputStreamWriter(stream);
39         NormalizedNodeWriter normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(writer);
40
41         normalizedNodeWriter.write(this.input);
42     }
43
44 }