public static Range decode(String value) { if (value == null) { throw new IllegalArgumentException(); } Range range; if (value.startsWith("{")) { try { range = new Range(JSONSerializer.parseMap(value)); } catch (SerializationException exception) { throw new IllegalArgumentException(exception); } } else { range = new Range(Time.decode(value)); } return range; } }
public static Range decode(String value) { if (value == null) { throw new IllegalArgumentException(); } Range range; if (value.startsWith("{")) { try { range = new Range(JSONSerializer.parseMap(value)); } catch (SerializationException exception) { throw new IllegalArgumentException(exception); } } else { range = new Range(Time.decode(value)); } return range; } }
public boolean intersects(Range range) { if (range == null) { throw new IllegalArgumentException("range is null."); } Range normalizedRange = range.normalize(); boolean intersects; if (start.compareTo(end) < 0) { intersects = (start.compareTo(normalizedRange.end) <= 0 && end.compareTo(normalizedRange.start) >= 0); } else { intersects = (end.compareTo(normalizedRange.end) <= 0 && start.compareTo(normalizedRange.start) >= 0); } return intersects; }
public boolean intersects(Range range) { if (range == null) { throw new IllegalArgumentException("range is null."); } Range normalizedRange = range.normalize(); boolean intersects; if (this.start.compareTo(this.end) < 0) { intersects = (this.start.compareTo(normalizedRange.end) <= 0 && this.end.compareTo(normalizedRange.start) >= 0); } else { intersects = (this.end.compareTo(normalizedRange.end) <= 0 && this.start.compareTo(normalizedRange.start) >= 0); } return intersects; }
public boolean contains(Range range) { if (range == null) { throw new IllegalArgumentException("range is null."); } Range normalizedRange = range.normalize(); boolean contains; if (this.start.compareTo(this.end) < 0) { contains = (this.start.compareTo(normalizedRange.start) <= 0 && this.end.compareTo(normalizedRange.end) >= 0); } else { contains = (this.end.compareTo(normalizedRange.start) <= 0 && this.start.compareTo(normalizedRange.end) >= 0); } return contains; }
public boolean contains(Range range) { if (range == null) { throw new IllegalArgumentException("range is null."); } Range normalizedRange = range.normalize(); boolean contains; if (start.compareTo(end) < 0) { contains = (start.compareTo(normalizedRange.start) <= 0 && end.compareTo(normalizedRange.end) >= 0); } else { contains = (end.compareTo(normalizedRange.start) <= 0 && start.compareTo(normalizedRange.end) >= 0); } return contains; }
public Range normalize() { Time earlier = (this.start.compareTo(this.end) < 0 ? this.start : this.end); Time later = (earlier == this.start ? this.end : this.start); return new Range(earlier, later); }
public Range normalize() { Time earlier = (start.compareTo(end) < 0 ? start : end); Time later = (earlier == start ? end : start); return new Range(earlier, later); }