Here you can find the source of assertParameterWithinBounds(String name, long lower, long upper, long parameter)
Parameter | Description |
---|---|
name | Name of the parameter to use in the Exception message. |
lower | Lower bound (inclusive). |
upper | Upper bound (inclusive). |
parameter | The parameter to test. |
Parameter | Description |
---|---|
IllegalArgumentException | Thrown when the parameter is out of bounds. |
public static void assertParameterWithinBounds(String name, long lower, long upper, long parameter)
//package com.java2s; /*/*from ww w . j a v a2 s .c o m*/ * Copyright (C) 2014 Lable (info@lable.nl) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Throw an {@link IllegalArgumentException} when a number is not within the supplied range. * * @param name Name of the parameter to use in the Exception message. * @param lower Lower bound (inclusive). * @param upper Upper bound (inclusive). * @param parameter The parameter to test. * @throws IllegalArgumentException Thrown when the parameter is out of bounds. */ public static void assertParameterWithinBounds(String name, long lower, long upper, long parameter) { if (parameter < lower || parameter > upper) { throw new IllegalArgumentException( String.format("Invalid %s: %d (expected: %d <= n < %d)", name, parameter, lower, upper + 1)); } } }