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.access;
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 ABIVersion}.
18 * @author Robert Varga
21 public abstract class AbstractVersionException extends Exception {
22 private static final long serialVersionUID = 1L;
23 private final @NonNull ABIVersion closestVersion;
24 private final int version;
26 AbstractVersionException(final String message, final short version, final ABIVersion closestVersion) {
28 this.closestVersion = requireNonNull(closestVersion);
29 this.version = Short.toUnsignedInt(version);
33 * Return the numeric version which has caused this exception.
35 * @return Numeric version
37 public final int getVersion() {
42 * Return the closest version supported by this codebase.
44 * @return Closest supported {@link ABIVersion}
46 public final @NonNull ABIVersion getClosestVersion() {
47 return closestVersion;