2 * Copyright (c) 2013 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.netconf.server.api.operations;
10 import static com.google.common.base.Preconditions.checkArgument;
12 import org.eclipse.jdt.annotation.NonNull;
14 public record HandlingPriority(int priority) implements Comparable<HandlingPriority> {
15 public static final @NonNull HandlingPriority HANDLE_WITH_DEFAULT_PRIORITY =
16 new HandlingPriority(Integer.MIN_VALUE);
17 public static final @NonNull HandlingPriority HANDLE_WITH_MAX_PRIORITY = new HandlingPriority(Integer.MAX_VALUE);
19 public HandlingPriority increasePriority(final int priorityIncrease) {
20 checkArgument(priorityIncrease > 0, "Negative increase");
21 checkArgument(Long.valueOf(priority) + priorityIncrease < Integer.MAX_VALUE,
22 "Resulting priority cannot be higher than %s", Integer.MAX_VALUE);
23 return new HandlingPriority(priority + priorityIncrease);
27 @SuppressWarnings("checkstyle:parameterName")
28 public int compareTo(final HandlingPriority o) {
29 return Integer.compare(priority, o.priority);