Here you can find the source of between(T lower, T upper, T value)
Parameter | Description |
---|---|
lower | Lower inclusive border. |
upper | Upper inclusive border. |
value | Value which will be tested. |
public static <T extends Comparable<T>> T between(T lower, T upper, T value)
//package com.java2s; /*//from w ww . ja va2 s . c o m * This file is part of Bukkit Plugin Utilities. * * Bukkit Plugin Utilities is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * Bukkit Plugin Utilities is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Bukkit Plugin Utilities. * If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Returns a value which is within the lower and upper borders. The borders * are inclusive. So if following is applying it returns the value, * otherwise the nearest border: <blockquote> * <code>lower <= value <= upper</code></blockquote> * * @param lower * Lower inclusive border. * @param upper * Upper inclusive border. * @param value * Value which will be tested. * @return The value within the given borders. * @since 1.3 */ public static <T extends Comparable<T>> T between(T lower, T upper, T value) { return (lower.compareTo(value) < 0) ? lower : ((upper.compareTo(value) > 0) ? upper : value); } }