X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fpersisted%2FShardDataTreeSnapshotMetadata.java;h=98302ee503710f9a95cf75b31f69bea6dc5ceefd;hb=55a9b9f42a14c56060f74b38f84d444c0fbfecc4;hp=a20ec4eba4e04461e30a30f1b470076dd2591a7b;hpb=b70b396725749d3fd6ca761f02f4b630f6f4f1ce;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshotMetadata.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshotMetadata.java index a20ec4eba4..98302ee503 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshotMetadata.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardDataTreeSnapshotMetadata.java @@ -7,26 +7,31 @@ */ package org.opendaylight.controller.cluster.datastore.persisted; -import com.google.common.base.Verify; +import static com.google.common.base.Verify.verifyNotNull; + import java.io.Externalizable; import java.io.Serializable; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; /** * Base class for various bits of metadata attached to a {@link MetadataShardDataTreeSnapshot}. This class is not * an interface because we want to make sure all subclasses implement the externalizable proxy pattern, for which - * we need to force {@link #readResolve()} to be abstract. + * we need to force {@link #writeReplace()} to be abstract. We do that by making it final and exposing a protected + * {@link #externalizableProxy()} method. * + *

* All concrete subclasses of this class should be final so as to form a distinct set of possible metadata. Since * metadata is serialized along with {@link MetadataShardDataTreeSnapshot}, this set is part of the serialization format * guarded by {@link PayloadVersion}. * + *

* If a new metadata type is introduced or a type is removed, {@link PayloadVersion} needs to be bumped to ensure * compatibility. * * @author Robert Varga */ -public abstract class ShardDataTreeSnapshotMetadata implements Serializable { +public abstract class ShardDataTreeSnapshotMetadata> + implements Serializable { private static final long serialVersionUID = 1L; ShardDataTreeSnapshotMetadata() { @@ -34,13 +39,15 @@ public abstract class ShardDataTreeSnapshotMetadata implements Serializable { } final Object writeReplace() { - return Verify.verifyNotNull(externalizableProxy(), "Null externalizable proxy from %s", getClass()); + return verifyNotNull(externalizableProxy(), "Null externalizable proxy from %s", getClass()); } /** - * Return an Externalizable proxy + * Return an Externalizable proxy. * * @return Externalizable proxy, may not be null */ - protected abstract @Nonnull Externalizable externalizableProxy(); + protected abstract @NonNull Externalizable externalizableProxy(); + + public abstract Class getType(); }