Example usage for com.google.common.collect Ranges atMost

List of usage examples for com.google.common.collect Ranges atMost

Introduction

In this page you can find the example usage for com.google.common.collect Ranges atMost.

Prototype

public static <C extends Comparable<?>> Range<C> atMost(C paramC) 

Source Link

Usage

From source file:com.sk89q.worldguard.blacklist.target.TargetMatcherParser.java

private Predicate<Short> parseRange(String input) throws TargetMatcherParseException {
    input = input.trim();/* ww  w. j  a  v  a  2  s .co m*/

    Matcher matcher;

    matcher = LESS_THAN_PATTERN.matcher(input);
    if (matcher.matches()) {
        return Ranges.atMost(Short.parseShort(matcher.group(1)));
    }

    matcher = GREATER_THAN_PATTERN.matcher(input);
    if (matcher.matches()) {
        return Ranges.atLeast(Short.parseShort(matcher.group(1)));
    }

    matcher = RANGE_PATTERN.matcher(input);
    if (matcher.matches()) {
        return Ranges.closed(Short.parseShort(matcher.group(1)), Short.parseShort(matcher.group(2)));
    }

    try {
        short s = Short.parseShort(input);
        return Ranges.closed(s, s);
    } catch (NumberFormatException e) {
        throw new TargetMatcherParseException("Unknown data value range: " + input);
    }
}