Example usage for org.apache.commons.lang.math Range getMaximumNumber

List of usage examples for org.apache.commons.lang.math Range getMaximumNumber

Introduction

In this page you can find the example usage for org.apache.commons.lang.math Range getMaximumNumber.

Prototype

public abstract Number getMaximumNumber();

Source Link

Document

Gets the maximum number in this range.

Usage

From source file:org.mili.core.lang.ASFValidate.java

/**
 * <p>/*from  w  w w. j av a 2 s . c o  m*/
 * Checks if a number is in range and throws <code>IllegalArgumentException</code>, if
 * number is out of range.
 * </p>
 *
 * <p>The method is used to check numbers in range or not. As example if a port parameter is
 * checked.</p>
 *
 * <pre>
 * ASFValidate.isInRange(13, new IntegerRange(1, 10), "Not in range!");
 * </pre>
 *
 * @param n number.
 * @param r range.
 * @param message message if number is not in range.
 * @throws IllegalArgumentException if number is not in range.
 */
public static void isInRange(Number n, Range r, String message) {
    Validate.notNull(n, "number can't be null!");
    Validate.notNull(r, "range can't be null!");
    if (message == null) {
        message = "The validated number[" + n + "] is not in range[" + r.getMinimumNumber() + ".."
                + r.getMaximumNumber() + "]";
    }
    Validate.isTrue(r.containsNumber(n), message);
}