Fix warnings/javadocs in sal-distributed-datastore
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / persisted / ShardDataTreeSnapshotMetadata.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.base.Verify;
11 import java.io.Externalizable;
12 import java.io.Serializable;
13 import javax.annotation.Nonnull;
14
15 /**
16  * Base class for various bits of metadata attached to a {@link MetadataShardDataTreeSnapshot}. This class is not
17  * an interface because we want to make sure all subclasses implement the externalizable proxy pattern, for which
18  * we need to force {@link #readResolve()} to be abstract.
19  * <p/>
20  * All concrete subclasses of this class should be final so as to form a distinct set of possible metadata. Since
21  * metadata is serialized along with {@link MetadataShardDataTreeSnapshot}, this set is part of the serialization format
22  * guarded by {@link PayloadVersion}.
23  * <p/>
24  * If a new metadata type is introduced or a type is removed, {@link PayloadVersion} needs to be bumped to ensure
25  * compatibility.
26  *
27  * @author Robert Varga
28  */
29 public abstract class ShardDataTreeSnapshotMetadata<T extends ShardDataTreeSnapshotMetadata<T>>
30         implements Serializable {
31     private static final long serialVersionUID = 1L;
32
33     ShardDataTreeSnapshotMetadata() {
34         // Prevent subclassing from outside of this package
35     }
36
37     final Object writeReplace() {
38         return Verify.verifyNotNull(externalizableProxy(), "Null externalizable proxy from %s", getClass());
39     }
40
41     /**
42      * Return an Externalizable proxy.
43      *
44      * @return Externalizable proxy, may not be null
45      */
46     protected abstract @Nonnull Externalizable externalizableProxy();
47
48     public abstract Class<T> getType();
49 }