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