Bug 7521: Convert DatastoreSnapshot.ShardSnapshot to store Snapshot
[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.IOException;
12 import java.io.ObjectOutput;
13 import java.util.Optional;
14 import javax.annotation.Nullable;
15 import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17
18 /**
19  * Legacy data tree snapshot used in versions prior to Boron, which contains only the data.
20  *
21  * @author Robert Varga
22  */
23 @Beta
24 public final class PreBoronShardDataTreeSnapshot extends ShardDataTreeSnapshot {
25     private final NormalizedNode<?, ?> rootNode;
26
27     @Deprecated
28     public PreBoronShardDataTreeSnapshot(final @Nullable NormalizedNode<?, ?> rootNode) {
29         this.rootNode = rootNode;
30     }
31
32     @Override
33     public Optional<NormalizedNode<?, ?>> getRootNode() {
34         return Optional.ofNullable(rootNode);
35     }
36
37     @Override
38     public void serialize(ObjectOutput out) throws IOException {
39         SerializationUtils.serializeNormalizedNode(rootNode, out);
40     }
41 }