/** * <p>Tests whether the specified <code>number</code> occurs within * this range using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param number the number to test, may be <code>null</code> * @return <code>true</code> if the specified number occurs within this range */ public boolean containsNumber(Number number) { if (number == null) { return false; } return containsInteger(number.intValue()); }
/** * <p>Tests whether the specified range occurs entirely within this range * using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param range the range to test, may be <code>null</code> * @return <code>true</code> if the specified range occurs entirely within this range * @throws IllegalArgumentException if the range is not of this type */ public boolean containsRange(Range range) { if (range == null) { return false; } return containsInteger(range.getMinimumInteger()) && containsInteger(range.getMaximumInteger()); }
/** * <p>Tests whether the specified range overlaps with this range * using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param range the range to test, may be <code>null</code> * @return <code>true</code> if the specified range overlaps with this range */ public boolean overlapsRange(Range range) { if (range == null) { return false; } return range.containsInteger(min) || range.containsInteger(max) || containsInteger(range.getMinimumInteger()); }
public static Pair<Integer,Integer> parse(String portRange) { int idx = portRange.indexOf('-'); if (idx != -1) { int low = Integer.parseInt(portRange.substring(0, idx)); int high = Integer.parseInt(portRange.substring(idx + 1)); if (!VALID_RANGE.containsInteger(low) || !VALID_RANGE.containsInteger(high) || !(low <= high)) { throw new IllegalArgumentException( "Invalid port range specified, only 1024 to 65535 supported."); } return new Pair<>(low, high); } throw new IllegalArgumentException( "Invalid port range specification, must use M-N notation."); }
public boolean useSplit(List<IntRange> useSplitList, int splitNumber) { boolean useSplit = false; for (IntRange range : useSplitList) { if (range.containsInteger(splitNumber)) { useSplit = true; break; } } return useSplit; } }
/** * <p>Tests whether the specified <code>number</code> occurs within * this range using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param number the number to test, may be <code>null</code> * @return <code>true</code> if the specified number occurs within this range */ public boolean containsNumber(Number number) { if (number == null) { return false; } return containsInteger(number.intValue()); }
/** * <p>Tests whether the specified <code>number</code> occurs within * this range using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param number the number to test, may be <code>null</code> * @return <code>true</code> if the specified number occurs within this range */ public boolean containsNumber(Number number) { if (number == null) { return false; } return containsInteger(number.intValue()); }
/** * <p>Tests whether the specified <code>number</code> occurs within * this range using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param number the number to test, may be <code>null</code> * @return <code>true</code> if the specified number occurs within this range */ public boolean containsNumber(Number number) { if (number == null) { return false; } return containsInteger(number.intValue()); }
/** * <p>Tests whether the specified <code>number</code> occurs within * this range using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param number the number to test, may be <code>null</code> * @return <code>true</code> if the specified number occurs within this range */ public boolean containsNumber(Number number) { if (number == null) { return false; } return containsInteger(number.intValue()); }
/** * <p>Tests whether the specified <code>number</code> occurs within * this range using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param number the number to test, may be <code>null</code> * @return <code>true</code> if the specified number occurs within this range */ public boolean containsNumber(Number number) { if (number == null) { return false; } return containsInteger(number.intValue()); }
public static Pair<Integer,Integer> parse(String portRange) { int idx = portRange.indexOf('-'); if (idx != -1) { int low = Integer.parseInt(portRange.substring(0, idx)); int high = Integer.parseInt(portRange.substring(idx + 1)); if (!VALID_RANGE.containsInteger(low) || !VALID_RANGE.containsInteger(high) || !(low <= high)) { throw new IllegalArgumentException( "Invalid port range specified, only 1024 to 65535 supported."); } return new Pair<>(low, high); } throw new IllegalArgumentException( "Invalid port range specification, must use M-N notation."); }
private static boolean validPortRange(int port) { return new IntRange(MIN_PORT, MAX_PORT).containsInteger(port); } }
/** * <p>Tests whether the specified range occurs entirely within this range * using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param range the range to test, may be <code>null</code> * @return <code>true</code> if the specified range occurs entirely within this range * @throws IllegalArgumentException if the range is not of this type */ public boolean containsRange(Range range) { if (range == null) { return false; } return containsInteger(range.getMinimumInteger()) && containsInteger(range.getMaximumInteger()); }
/** * <p>Tests whether the specified range occurs entirely within this range * using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param range the range to test, may be <code>null</code> * @return <code>true</code> if the specified range occurs entirely within this range * @throws IllegalArgumentException if the range is not of this type */ public boolean containsRange(Range range) { if (range == null) { return false; } return containsInteger(range.getMinimumInteger()) && containsInteger(range.getMaximumInteger()); }
/** * <p>Tests whether the specified range occurs entirely within this range * using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param range the range to test, may be <code>null</code> * @return <code>true</code> if the specified range occurs entirely within this range * @throws IllegalArgumentException if the range is not of this type */ public boolean containsRange(Range range) { if (range == null) { return false; } return containsInteger(range.getMinimumInteger()) && containsInteger(range.getMaximumInteger()); }
/** * <p>Tests whether the specified range occurs entirely within this range * using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param range the range to test, may be <code>null</code> * @return <code>true</code> if the specified range occurs entirely within this range * @throws IllegalArgumentException if the range is not of this type */ public boolean containsRange(Range range) { if (range == null) { return false; } return containsInteger(range.getMinimumInteger()) && containsInteger(range.getMaximumInteger()); }
List<IntRange> ranges = new ArrayList<IntRange>() {{ add(new IntRange(0, 2)); add(new IntRange(2, 6)); add(new IntRange(6, 0)); }}; public boolean inRange(int n, List<IntRange> ranges) { for (IntRange range : ranges) { if (range.containsInteger(n)) { return true; } } return false; }
/** * <p>Tests whether the specified range overlaps with this range * using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param range the range to test, may be <code>null</code> * @return <code>true</code> if the specified range overlaps with this range */ public boolean overlapsRange(Range range) { if (range == null) { return false; } return range.containsInteger(min) || range.containsInteger(max) || containsInteger(range.getMinimumInteger()); }
/** * <p>Tests whether the specified range overlaps with this range * using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param range the range to test, may be <code>null</code> * @return <code>true</code> if the specified range overlaps with this range */ public boolean overlapsRange(Range range) { if (range == null) { return false; } return range.containsInteger(min) || range.containsInteger(max) || containsInteger(range.getMinimumInteger()); }
/** * <p>Tests whether the specified range overlaps with this range * using <code>int</code> comparison.</p> * * <p><code>null</code> is handled and returns <code>false</code>.</p> * * @param range the range to test, may be <code>null</code> * @return <code>true</code> if the specified range overlaps with this range */ public boolean overlapsRange(Range range) { if (range == null) { return false; } return range.containsInteger(min) || range.containsInteger(max) || containsInteger(range.getMinimumInteger()); }