7be0d85c7a2f00cf557fc17ff379bbab4ecdb2dd
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / persisted / PreBoronShardDataTreeSnapshot.java
1 /*
2  * Copyright (c) 2016 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 package org.opendaylight.controller.cluster.datastore.persisted;
9
10 import com.google.common.annotations.Beta;
11 import java.io.DataOutputStream;
12 import java.io.IOException;
13 import java.io.OutputStream;
14 import java.util.Optional;
15 import javax.annotation.Nullable;
16 import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
17 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18
19 /**
20  * Legacy data tree snapshot used in versions prior to Boron, which contains only the data.
21  *
22  * @author Robert Varga
23  */
24 @Beta
25 public final class PreBoronShardDataTreeSnapshot extends ShardDataTreeSnapshot {
26     private final NormalizedNode<?, ?> rootNode;
27
28     @Deprecated
29     public PreBoronShardDataTreeSnapshot(final @Nullable NormalizedNode<?, ?> rootNode) {
30         this.rootNode = rootNode;
31     }
32
33     @Override
34     public Optional<NormalizedNode<?, ?>> getRootNode() {
35         return Optional.ofNullable(rootNode);
36     }
37
38     @Override
39     public void serialize(OutputStream os) throws IOException {
40         try (final DataOutputStream dos = new DataOutputStream(os)) {
41             SerializationUtils.serializeNormalizedNode(rootNode, dos);
42         }
43     }
44 }