Here you can find the source of assertInBounds(final String param, final int value, final int min, final int max)
Parameter | Description |
---|---|
param | A <code>String</code> that represents the name of the parameter, which becomes the exception message text if the <code>value</code> parameter is out of bounds. |
value | The value of the specified parameter. |
min | The minimum value for the specified parameter. |
max | The maximum value for the specified parameter. |
public static void assertInBounds(final String param, final int value, final int min, final int max)
//package com.java2s; /**// ww w . j a v a 2 s . c o m * Copyright Microsoft Corporation * * 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 { /** * Asserts that the specified integer is in the valid range. * * @param param * A <code>String</code> that represents the name of the parameter, which becomes the exception message * text if the <code>value</code> parameter is out of bounds. * @param value * The value of the specified parameter. * @param min * The minimum value for the specified parameter. * @param max * The maximum value for the specified parameter. */ public static void assertInBounds(final String param, final int value, final int min, final int max) { if (value < min || value > max) { throw new IllegalArgumentException( String.format("The value of the parameter %s should be between %s and %s.", param, min, max)); } } }