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 com.google.common.annotations.Beta;
11 import com.google.common.base.Preconditions;
12 import javax.annotation.Nonnull;
15 * Abstract base exception used for reporting version mismatches from {@link ABIVersion}.
17 * @author Robert Varga
20 public abstract class AbstractVersionException extends Exception {
21 private static final long serialVersionUID = 1L;
22 private final ABIVersion closestVersion;
23 private final int version;
25 AbstractVersionException(final String message, final short version, final ABIVersion closestVersion) {
27 this.closestVersion = Preconditions.checkNotNull(closestVersion);
28 this.version = Short.toUnsignedInt(version);
32 * Return the numeric version which has caused this exception.
34 * @return Numeric version
36 public final int getVersion() {
41 * Return the closest version supported by this codebase.
43 * @return Closest supported {@link ABIVersion}
46 public final ABIVersion getClosestVersion() {
47 return closestVersion;