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 java.io.Serial;
13 import org.eclipse.jdt.annotation.NonNull;
16 * Abstract base exception used for reporting version mismatches from {@link ABIVersion}.
18 public abstract class AbstractVersionException extends Exception {
20 private static final long serialVersionUID = 1L;
22 private final @NonNull ABIVersion closestVersion;
23 private final int version;
25 AbstractVersionException(final String message, final short version, final ABIVersion closestVersion) {
27 this.closestVersion = requireNonNull(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 version() {
41 * Return the closest version supported by this codebase.
43 * @return Closest supported {@link ABIVersion}
45 public final @NonNull ABIVersion closestVersion() {
46 return closestVersion;