Example usage for org.apache.wicket.util.lang Args withinRange

List of usage examples for org.apache.wicket.util.lang Args withinRange

Introduction

In this page you can find the example usage for org.apache.wicket.util.lang Args withinRange.

Prototype

public static <T extends Comparable<? super T>> T withinRange(final T min, final T max, final T value,
        final String name) 

Source Link

Document

Checks if argument is within a range

Usage

From source file:de.alpharogroup.wicket.js.addon.core.PercentNumberFormatTextValue.java

License:Apache License

/**
 * Checks the given value if it is between 0 to 100 quietly. If not a default value from 50 will
 * be set.//from   w  w w .  j  ava  2s  .c  o m
 *
 * @param name
 *            the name
 * @param value
 *            the value
 * @return the integer
 */
private static Integer checkQuietly(final String name, final Integer value) {
    Integer val = 50;
    try {
        val = Args.withinRange(0, 100, value, name);
    } catch (final IllegalArgumentException e) {
        LOGGER.error(String.format(
                "Given argument '%s' must have a value within [%s,%s], but was %s. Default value 50% will be set.",
                name, 0, 100, value));
    }
    return val;

}

From source file:sk.drunkenpanda.leaflet.models.AbstractLatLng.java

License:Apache License

@Value.Check
protected void check() {
    Args.withinRange(-90.0, 90.0, getLatitude(), "latitude");
    Args.withinRange(-180.0, 180.0, getLongitude(), "longitude");
}

From source file:sk.drunkenpanda.leaflet.models.LatLng.java

License:Apache License

/**
 * Constructor creates new point with given latitude and longitude.
 * //w ww  .  jav  a2s  .  co  m
 * @param latitude latitude of point in degrees
 * @param longitude longitude of point in degrees
 * @throws IllegalArgumentException if {@code latitude} is not in range [-90, 90]
 *  or longitude is not in range [-180, 180].
 */
public LatLng(double latitude, double longitude) {
    Args.withinRange(-90.0, 90.0, latitude, "latitude");
    Args.withinRange(-180.0, 180.0, longitude, "longitude");
    this.latitude = latitude;
    this.longitude = longitude;
}