2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.datastore.persisted;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.Beta;
13 import org.eclipse.jdt.annotation.NonNull;
16 * Abstract base exception used for reporting version mismatches from {@link PayloadVersion}.
18 * @author Robert Varga
21 public abstract class AbstractVersionException extends Exception {
22 private static final long serialVersionUID = 1L;
24 private final @NonNull PayloadVersion closestVersion;
25 private final int version;
27 AbstractVersionException(final String message, final short version, final PayloadVersion closestVersion) {
29 this.closestVersion = requireNonNull(closestVersion);
30 this.version = Short.toUnsignedInt(version);
34 * Return the numeric version which has caused this exception.
36 * @return Numeric version
38 public final int getVersion() {
43 * Return the closest version supported by this codebase.
45 * @return Closest supported {@link PayloadVersion}
47 public final @NonNull PayloadVersion getClosestVersion() {
48 return closestVersion;