/** * @return if range is empty range. */ public boolean isEmpty() { return begin.equals(end); }
/** * @return if range is empty range. */ public boolean isEmpty() { return begin.equals(end); }
@Override public boolean drop(@NonNull TimePartition toDrop) throws LensException { if (first.equals(latest) && first.equals(toDrop)) { this.first = null; this.latest = null; this.holes.clear(); return true; } else if (first.equals(toDrop)) { this.first = this.getNextPartition(first, latest, 1); return true; } else if (latest.equals(toDrop)) { this.latest = this.getNextPartition(latest, first, -1); return true; } else { return addHole(toDrop); } }
@Override public boolean drop(@NonNull TimePartition toDrop) throws LensException { if (first.equals(latest) && first.equals(toDrop)) { this.first = null; this.latest = null; this.holes.clear(); return true; } else if (first.equals(toDrop)) { this.first = this.getNextPartition(first, latest, 1); return true; } else if (latest.equals(toDrop)) { this.latest = this.getNextPartition(latest, first, -1); return true; } else { return addHole(toDrop); } }
@Override public boolean drop(TimePartition toDrop) throws LensException { int ind = getStrictlyAfterIndex(toDrop); if (ind == 0) { return true; // nothing to do } if (ranges.get(ind - 1).getBegin().equals(toDrop)) { ranges.get(ind - 1).setBegin(toDrop.next()); } else if (ranges.get(ind - 1).getEnd().previous().equals(toDrop)) { ranges.get(ind - 1).setEnd(toDrop); } else { TimePartition end = ranges.get(ind - 1).getEnd(); ranges.get(ind - 1).setEnd(toDrop); ranges.add(ind, toDrop.next().rangeUpto(end)); } if (ranges.get(ind - 1).isEmpty()) { ranges.remove(ind - 1); } return true; }
@Override public boolean drop(TimePartition toDrop) throws LensException { int ind = getStrictlyAfterIndex(toDrop); if (ind == 0) { return true; // nothing to do } if (ranges.get(ind - 1).getBegin().equals(toDrop)) { ranges.get(ind - 1).setBegin(toDrop.next()); } else if (ranges.get(ind - 1).getEnd().previous().equals(toDrop)) { ranges.get(ind - 1).setEnd(toDrop); } else { TimePartition end = ranges.get(ind - 1).getEnd(); ranges.get(ind - 1).setEnd(toDrop); ranges.add(ind, toDrop.next().rangeUpto(end)); } if (ranges.get(ind - 1).isEmpty()) { ranges.remove(ind - 1); } return true; }