Example usage for com.google.common.collect Range equals

List of usage examples for com.google.common.collect Range equals

Introduction

In this page you can find the example usage for com.google.common.collect Range equals.

Prototype

@Override
public boolean equals(@Nullable Object object) 

Source Link

Document

Returns true if object is a range having the same endpoints and bound types as this range.

Usage

From source file:net.bican.iplib.IPAddresses.java

/**
 * transforms the range to CIDR notation, if any is possible
 *
 * @param range//w  ww .ja  va2s .c o m
 *          the range to transform
 * @return transformed CIDR range
 */
public static CIDR toCIDR(final Range<IPAddress> range) {
    Preconditions.checkNotNull(range, "range cannot be null"); //$NON-NLS-1$
    if (range.isEmpty()) {
        return null;
    }
    int prefix = 0;
    final LongDiscreteDomain<IPAddress> domain = range.lowerEndpoint().getDomain();
    final Range<IPAddress> addrRange = IPAddresses.canonical(range, domain);
    while (prefix <= domain.maxPrefix()) {
        final CIDR cidr = new CIDR(addrRange.lowerEndpoint(), prefix);
        final Range<IPAddress> a = IPAddresses.fromCIDR(cidr);
        if (a.equals(addrRange)) {
            return cidr;
        }
        prefix++;
    }
    return null;
}

From source file:org.apache.kylin.common.util.RangeUtil.java

/**
 * for NavigableMap sorted by C, given a range of C, return the sub map whose key falls in the range
 *//* ww  w  .j av a  2s .c  o  m*/
public static <C extends Comparable<?>, V> NavigableMap<C, V> filter(NavigableMap<C, V> values,
        Range<C> filterRange) {
    if (filterRange == null || filterRange.isEmpty()) {
        return Maps.newTreeMap();
    } else if (filterRange.equals(Range.all())) {
        return values;
    }

    if (filterRange.hasUpperBound() && !filterRange.hasLowerBound()) {
        return values.headMap(filterRange.upperEndpoint(), upperBoundInclusive(filterRange));
    } else if (filterRange.hasLowerBound() && !filterRange.hasUpperBound()) {
        return values.tailMap(filterRange.lowerEndpoint(), lowerBoundInclusive(filterRange));
    } else {
        return values.subMap(filterRange.lowerEndpoint(), lowerBoundInclusive(filterRange), //
                filterRange.upperEndpoint(), upperBoundInclusive(filterRange));
    }
}

From source file:net.bican.iplib.IPAddresses.java

private static Set<Range<IPAddress>> findOneConnected(final Set<Range<IPAddress>> intervals) {
    Range<IPAddress> f1 = null;//w  ww  .  j  ava  2  s .  co m
    Range<IPAddress> f2 = null;
    for (final Range<IPAddress> s : intervals) {
        for (final Range<IPAddress> s2 : intervals) {
            final Range<IPAddress> sc = IPAddresses.canonical(s, s.lowerEndpoint().getDomain());
            final Range<IPAddress> sc2 = IPAddresses.canonical(s, s2.lowerEndpoint().getDomain());
            if ((sc.equals(sc2)) || (s.isConnected(s2))) {
                f1 = s;
                f2 = s2;
                break;
            }
        }
        if (f1 != null) {
            break;
        }
    }
    if (f1 != null) {
        final Set<Range<IPAddress>> newIntervals = new TreeSet<>(IPAddressRangeComparator.getComparator());
        newIntervals.addAll(intervals);
        final Range<IPAddress> f = f1.span(f2);
        newIntervals.remove(f1);
        newIntervals.remove(f2);
        newIntervals.add(f);
        return newIntervals;
    }
    return intervals;
}

From source file:net.bican.iplib.IPAddresses.java

private static Set<Range<IPAddress>> fromConnectedInterval(final Range<IPAddress> interval) {
    if (interval.isEmpty()) {
        return null;
    }//from  w  ww.j a  v a2s . c om
    int prefix = 0;
    final LongDiscreteDomain<IPAddress> domain = interval.lowerEndpoint().getDomain();
    while (prefix <= domain.maxPrefix()) {
        final Range<IPAddress> thisRange = IPAddresses.canonical(interval, domain);
        final Range<IPAddress> otherRange = IPAddresses.fromCIDR(new CIDR(thisRange.lowerEndpoint(), prefix));
        if (thisRange.equals(otherRange)) {
            TreeSet<Range<IPAddress>> result = new TreeSet<>(IPAddressRangeComparator.getComparator());
            result.add(otherRange);
            return result;
        } else if (thisRange.encloses(otherRange)) {
            final Set<Range<IPAddress>> result = new TreeSet<>(IPAddressRangeComparator.getComparator());
            result.add(otherRange);
            Range<IPAddress> newRange1 = Range.closedOpen(thisRange.lowerEndpoint(),
                    otherRange.lowerEndpoint());
            Range<IPAddress> newRange2 = Range.openClosed(otherRange.upperEndpoint(),
                    thisRange.upperEndpoint());
            final Set<Range<IPAddress>> results1 = IPAddresses.fromConnectedInterval(newRange1);
            if (results1 != null) {
                result.addAll(results1);
            }
            final Set<Range<IPAddress>> results2 = IPAddresses.fromConnectedInterval(newRange2);
            if (results2 != null) {
                result.addAll(results2);
            }
            return result;
        }
        prefix++;
    }
    return new TreeSet<>(Collections.singleton(interval));
}

From source file:net.bican.iplib.IPAddressRangeComparator.java

@Override
public int compare(Range<IPAddress> o1, Range<IPAddress> o2) {
    if (o1.equals(o2)) {
        return 0;
    }//from   w w w  . j a v a  2 s .c  o m
    Range<IPAddress> oo1 = IPAddresses.canonical(o1, o1.lowerEndpoint().getDomain());
    Range<IPAddress> oo2 = IPAddresses.canonical(o2, o2.lowerEndpoint().getDomain());
    return oo1.lowerEndpoint().compareTo(oo2.lowerEndpoint());
}

From source file:org.apache.kylin.storage.cache.StreamSQLResult.java

public Range<Long> getReusableResults(Range<Long> tsRange) {

    if (tsRange.equals(timeCovered))
        return timeCovered;

    if (!timeCovered.isConnected(tsRange)) {
        //share nothing in common
        return null;
    }//from   w ww  .j a  va 2  s.co m

    Range<Long> ret = timeCovered.intersection(tsRange);
    return ret.isEmpty() ? null : ret;
}

From source file:com.google.googlejavaformat.java.JavaOutput.java

/**
 * Emit a list of {@link Replacement}s to convert from input to output.
 *
 * @return a list of {@link Replacement}s, sorted by start index, without overlaps
 *///ww w.j  a va 2  s.  co m
public ImmutableList<Replacement> getFormatReplacements(RangeSet<Integer> iRangeSet0) {
    ImmutableList.Builder<Replacement> result = ImmutableList.builder();
    Map<Integer, Range<Integer>> kToJ = JavaOutput.makeKToIJ(this);

    // Expand the token ranges to align with re-formattable boundaries.
    RangeSet<Integer> breakableRanges = TreeRangeSet.create();
    RangeSet<Integer> iRangeSet = iRangeSet0.subRangeSet(Range.closed(0, javaInput.getkN()));
    for (Range<Integer> iRange : iRangeSet.asRanges()) {
        Range<Integer> range = expandToBreakableRegions(iRange.canonical(DiscreteDomain.integers()));
        if (range.equals(EMPTY_RANGE)) {
            // the range contains only whitespace
            continue;
        }
        breakableRanges.add(range);
    }

    // Construct replacements for each reformatted region.
    for (Range<Integer> range : breakableRanges.asRanges()) {

        Input.Tok startTok = startTok(javaInput.getToken(range.lowerEndpoint()));
        Input.Tok endTok = endTok(javaInput.getToken(range.upperEndpoint() - 1));

        // Add all output lines in the given token range to the replacement.
        StringBuilder replacement = new StringBuilder();

        int replaceFrom = startTok.getPosition();
        // Replace leading whitespace in the input with the whitespace from the formatted file
        while (replaceFrom > 0) {
            char previous = javaInput.getText().charAt(replaceFrom - 1);
            if (!CharMatcher.whitespace().matches(previous)) {
                break;
            }
            replaceFrom--;
        }

        int i = kToJ.get(startTok.getIndex()).lowerEndpoint();
        // Include leading blank lines from the formatted output, unless the formatted range
        // starts at the beginning of the file.
        while (i > 0 && getLine(i - 1).isEmpty()) {
            i--;
        }
        // Write out the formatted range.
        for (; i < kToJ.get(endTok.getIndex()).upperEndpoint(); i++) {
            // It's possible to run out of output lines (e.g. if the input ended with
            // multiple trailing newlines).
            if (i < getLineCount()) {
                if (i > 0) {
                    replacement.append(lineSeparator);
                }
                replacement.append(getLine(i));
            }
        }

        int replaceTo = Math.min(endTok.getPosition() + endTok.length(), javaInput.getText().length());
        // If the formatted ranged ended in the trailing trivia of the last token before EOF,
        // format all the way up to EOF to deal with trailing whitespace correctly.
        if (endTok.getIndex() == javaInput.getkN() - 1) {
            replaceTo = javaInput.getText().length();
        }
        // Replace trailing whitespace in the input with the whitespace from the formatted file.
        // If the trailing whitespace in the input includes one or more line breaks, preserve the
        // whitespace after the last newline to avoid re-indenting the line following the formatted
        // line.
        int newline = -1;
        while (replaceTo < javaInput.getText().length()) {
            char next = javaInput.getText().charAt(replaceTo);
            if (!CharMatcher.whitespace().matches(next)) {
                break;
            }
            int newlineLength = Newlines.hasNewlineAt(javaInput.getText(), replaceTo);
            if (newlineLength != -1) {
                newline = replaceTo;
                // Skip over the entire newline; don't count the second character of \r\n as a newline.
                replaceTo += newlineLength;
            } else {
                replaceTo++;
            }
        }
        if (newline != -1) {
            replaceTo = newline;
        }

        if (newline == -1) {
            // There wasn't an existing trailing newline; add one.
            replacement.append(lineSeparator);
        }
        for (; i < getLineCount(); i++) {
            String after = getLine(i);
            int idx = CharMatcher.whitespace().negate().indexIn(after);
            if (idx == -1) {
                // Write out trailing empty lines from the formatted output.
                replacement.append(lineSeparator);
            } else {
                if (newline == -1) {
                    // If there wasn't a trailing newline in the input, indent the next line.
                    replacement.append(after.substring(0, idx));
                }
                break;
            }
        }

        result.add(Replacement.create(replaceFrom, replaceTo, replacement.toString()));
    }
    return result.build();
}

From source file:jetbrains.jetpad.hybrid.HybridSynchronizer.java

private CellTrait createTargetTrait() {
    return new CellTrait() {
        @Override/*from   w  w  w  .j  av  a2s  .  c  o  m*/
        public Object get(Cell cell, CellTraitPropertySpec<?> spec) {
            if (spec == HYBRID_SYNCHRONIZER) {
                return HybridSynchronizer.this;
            }
            if (spec == CellStateHandler.PROPERTY) {
                return getCellStateHandler();
            }

            return super.get(cell, spec);
        }

        @Override
        public void onKeyPressed(Cell cell, KeyEvent event) {
            Cell focusedCell = cell.cellContainer().get().focusedCell.get();
            if (myTargetList.contains(focusedCell)) {
                Cell currentCell = cell.cellContainer().get().focusedCell.get();
                if (!hasSelection()) {
                    if (event.is(KeyStrokeSpecs.SELECT_UP) && currentCell != null) {
                        mySelectionSupport.select(currentCell, currentCell);
                        event.consume();
                    }
                } else {
                    Range<Integer> currentRange = selection();
                    if (event.is(KeyStrokeSpecs.SELECT_UP)) {
                        ParseNode parseNode = myTokenListEditor.parseNode();
                        if (parseNode != null) {
                            if (!currentRange.equals(parseNode.range())) {
                                ParseNode node = ParseNodes.findForRange(parseNode, currentRange);
                                ParseNode parentNode = ParseNodes.nonSameRangeParent(node);
                                if (parentNode != null) {
                                    select(parentNode.range());
                                    event.consume();
                                }
                            }
                        } else {
                            if (!currentRange.equals(Range.closed(0, tokens().size()))) {
                                select(Range.closed(0, tokens().size()));
                                event.consume();
                            }
                        }
                    }

                    if (event.is(KeyStrokeSpecs.SELECT_DOWN)) {
                        ParseNode parseNode = myTokenListEditor.parseNode();
                        if (parseNode != null) {
                            ParseNode node = ParseNodes.findForRange(parseNode, currentRange);
                            ParseNode childNode = ParseNodes.nonSameRangeChild(node,
                                    myTargetList.indexOf(mySelectionSupport.currentCell()));
                            if (childNode != null) {
                                select(childNode.range());
                                event.consume();
                                return;
                            }
                        }

                        if (!mySelectionSupport.isCurrentCompletelySelected()) {
                            mySelectionSupport.clearSelection();
                            event.consume();
                        }
                    }
                }
            }
            super.onKeyPressed(cell, event);
        }

        @Override
        public void onCopy(Cell cell, CopyCutEvent event) {
            if (canCopy()) {
                event.consume(copy());
                return;
            }
            super.onCopy(cell, event);
        }

        @Override
        public void onCut(Cell cell, CopyCutEvent event) {
            if (canCut()) {
                event.consume(cut());
                return;
            }
            super.onCut(cell, event);
        }

        @Override
        public void onPaste(Cell cell, PasteEvent event) {
            if (canPaste(event.getContent())) {
                paste(event.getContent());
                event.consume();
                return;
            }
            super.onPaste(cell, event);
        }

        private boolean canPaste(ClipboardContent content) {
            return content.isSupported(TOKENS_CONTENT);
        }

        private void paste(ClipboardContent content) {
            List<Token> tokens = content.get(TOKENS_CONTENT);
            Cell currentCell = mySelectionSupport.currentCell();

            int targetIndex;
            if (currentCell != null) {
                int currentCellIndex = myTargetList.indexOf(currentCell);
                targetIndex = Positions.isHomePosition(currentCell) ? currentCellIndex : currentCellIndex + 1;
            } else {
                targetIndex = 0;
            }

            myTokenListEditor.tokens.addAll(targetIndex, tokens);
            myTokenListEditor.updateToPrintedTokens();
            tokenOperations().select(targetIndex + tokens.size() - 1, LAST).run();
        }

        private boolean canCopy() {
            return hasSelection();
        }

        private ClipboardContent copy() {
            final Range<Integer> selection = selection();
            final List<Token> tokens = new ArrayList<>(
                    tokens().subList(selection.lowerEndpoint(), selection.upperEndpoint()));
            return new ClipboardContent() {
                @Override
                public boolean isSupported(ContentKind<?> kind) {
                    return kind == TOKENS_CONTENT;
                }

                @Override
                public <T> T get(ContentKind<T> kind) {
                    if (kind == TOKENS_CONTENT) {
                        return (T) Collections.unmodifiableList(tokens);
                    }
                    return null;
                }
            };
        }

        private boolean canCut() {
            return hasSelection();
        }

        private ClipboardContent cut() {
            ClipboardContent result = copy();
            clearSelection();
            return result;
        }
    };
}

From source file:jetbrains.jetpad.hybrid.BaseHybridSynchronizer.java

private CellTrait createTargetTrait() {
    return new CellTrait() {
        @Override//from   w w  w  .ja va2s .com
        public Object get(Cell cell, CellTraitPropertySpec<?> spec) {
            if (spec == HYBRID_SYNCHRONIZER) {
                return BaseHybridSynchronizer.this;
            }
            if (spec == CellStateHandler.PROPERTY) {
                return getCellStateHandler();
            }

            return super.get(cell, spec);
        }

        @Override
        public void onKeyPressed(Cell cell, KeyEvent event) {
            Cell focusedCell = cell.getContainer().focusedCell.get();
            if (myTargetList.contains(focusedCell)) {
                Cell currentCell = cell.getContainer().focusedCell.get();
                if (!hasSelection()) {
                    if (event.is(KeyStrokeSpecs.SELECT_UP) && currentCell != null) {
                        mySelectionSupport.select(currentCell, currentCell);
                        event.consume();
                    }
                } else {
                    Range<Integer> currentRange = selection();
                    if (event.is(KeyStrokeSpecs.SELECT_UP)) {
                        ParseNode parseNode = myTokenListEditor.getParseNode();
                        if (parseNode != null) {
                            if (!currentRange.equals(parseNode.getRange())) {
                                ParseNode node = ParseNodes.findForRange(parseNode, currentRange);
                                ParseNode parentNode = ParseNodes.nonSameRangeParent(node);
                                if (parentNode != null) {
                                    select(parentNode.getRange());
                                    event.consume();
                                }
                            }
                        } else {
                            if (!currentRange.equals(Range.closed(0, tokens().size()))) {
                                select(Range.closed(0, tokens().size()));
                                event.consume();
                            }
                        }
                    }

                    if (event.is(KeyStrokeSpecs.SELECT_DOWN)) {
                        ParseNode parseNode = myTokenListEditor.getParseNode();
                        if (parseNode != null) {
                            ParseNode node = ParseNodes.findForRange(parseNode, currentRange);
                            ParseNode childNode = ParseNodes.nonSameRangeChild(node,
                                    myTargetList.indexOf(mySelectionSupport.currentCell()));
                            if (childNode != null) {
                                select(childNode.getRange());
                                event.consume();
                                return;
                            }
                        }

                        if (!mySelectionSupport.isCurrentCompletelySelected()) {
                            mySelectionSupport.clearSelection();
                            event.consume();
                        }
                    }
                }
            }
            super.onKeyPressed(cell, event);
        }

        @Override
        public void onCopy(Cell cell, CopyCutEvent event) {
            if (canCopy()) {
                event.consume(copy());
                return;
            }
            super.onCopy(cell, event);
        }

        @Override
        public void onCut(Cell cell, CopyCutEvent event) {
            if (canCut()) {
                ClipboardContent content = cut();
                myTokensEditPostProcessor.afterTokensEdit(tokens(), property().get());
                event.consume(content);
                return;
            }
            super.onCut(cell, event);
        }

        @Override
        public void onPaste(Cell cell, PasteEvent event) {
            if (canPaste(event.getContent())) {
                paste(event.getContent());
                myTokensEditPostProcessor.afterTokensEdit(tokens(), property().get());
                event.consume();
                return;
            }
            super.onPaste(cell, event);
        }

        private boolean canPaste(ClipboardContent content) {
            return content.isSupported(TOKENS_CONTENT);
        }

        private void paste(ClipboardContent content) {
            List<Token> tokens = content.get(TOKENS_CONTENT);
            Cell currentCell = mySelectionSupport.currentCell();

            int targetIndex;
            if (currentCell != null) {
                int currentCellIndex = myTargetList.indexOf(currentCell);
                boolean home = Positions.isHomePosition(currentCell);
                boolean end = Positions.isEndPosition(currentCell);
                if (home && end) {
                    // One-char token which allows editing at only one side
                    if (currentCell instanceof TextTokenCell && ((TextTokenCell) currentCell).noSpaceToLeft()) {
                        targetIndex = currentCellIndex + 1;
                    } else {
                        targetIndex = currentCellIndex;
                    }
                } else if (home) {
                    targetIndex = currentCellIndex;
                } else {
                    targetIndex = currentCellIndex + 1;
                }
            } else {
                targetIndex = 0;
            }

            myTokenListEditor.tokens.addAll(targetIndex, tokens);
            myTokenListEditor.updateToPrintedTokens();
            tokenOperations().select(targetIndex + tokens.size() - 1, LAST).run();
        }

        private boolean canCopy() {
            return hasSelection();
        }

        private ClipboardContent copy() {
            final Range<Integer> selection = selection();
            final List<Token> copiedTokens = new ArrayList<>(
                    selection.upperEndpoint() - selection.lowerEndpoint());
            for (Token token : tokens().subList(selection.lowerEndpoint(), selection.upperEndpoint())) {
                copiedTokens.add(token.copy());
            }
            return new ClipboardContent() {
                @Override
                public boolean isSupported(ContentKind<?> kind) {
                    return kind == TOKENS_CONTENT;
                }

                @Override
                public <T> T get(ContentKind<T> kind) {
                    if (kind == TOKENS_CONTENT) {
                        List<Token> result = new ArrayList<>(copiedTokens.size());
                        for (Token token : copiedTokens) {
                            result.add(token.copy());
                        }
                        return (T) Collections.unmodifiableList(result);
                    }
                    return null;
                }

                @Override
                public String toString() {
                    try {
                        return TokenUtil.getText(copiedTokens);
                    } catch (UnsupportedOperationException e) {
                        return super.toString();
                    }
                }
            };
        }

        private boolean canCut() {
            return hasSelection();
        }

        private ClipboardContent cut() {
            ClipboardContent result = copy();
            clearSelection();
            return result;
        }
    };
}

From source file:net.sourceforge.ganttproject.task.algorithm.SchedulerImpl.java

private void schedule(Node node) {
    Logger logger = GPLogger.getLogger(this);
    GPLogger.debug(logger, "Scheduling node %s", node);
    Range<Date> startRange = Range.all();
    Range<Date> endRange = Range.all();

    Range<Date> weakStartRange = Range.all();
    Range<Date> weakEndRange = Range.all();

    List<Date> subtaskRanges = Lists.newArrayList();
    List<DependencyEdge> incoming = node.getIncoming();
    GPLogger.debug(logger, ".. #incoming edges=%d", incoming.size());
    for (DependencyEdge edge : incoming) {
        if (!edge.refresh()) {
            continue;
        }//from w w  w . ja  va 2 s  . c om
        if (edge instanceof ImplicitSubSuperTaskDependency) {
            subtaskRanges.add(edge.getStartRange().upperEndpoint());
            subtaskRanges.add(edge.getEndRange().lowerEndpoint());
        } else {
            if (edge.isWeak()) {
                weakStartRange = weakStartRange.intersection(edge.getStartRange());
                weakEndRange = weakEndRange.intersection(edge.getEndRange());
            } else {
                startRange = startRange.intersection(edge.getStartRange());
                endRange = endRange.intersection(edge.getEndRange());
            }
        }
        if (startRange.isEmpty() || endRange.isEmpty()) {
            GPLogger.logToLogger("both start and end ranges were calculated as empty for task=" + node.getTask()
                    + ". Skipping it");
        }
    }
    GPLogger.debug(logger, "..Ranges: start=%s end=%s weakStart=%s weakEnd=%s", startRange, endRange,
            weakStartRange, weakEndRange);

    Range<Date> subtasksSpan = subtaskRanges.isEmpty()
            ? Range.closed(node.getTask().getStart().getTime(), node.getTask().getEnd().getTime())
            : Range.encloseAll(subtaskRanges);
    Range<Date> subtreeStartUpwards = subtasksSpan
            .span(Range.downTo(node.getTask().getStart().getTime(), BoundType.CLOSED));
    Range<Date> subtreeEndDownwards = subtasksSpan
            .span(Range.upTo(node.getTask().getEnd().getTime(), BoundType.CLOSED));
    GPLogger.debug(logger, "..Subtasks span=%s", subtasksSpan);

    if (!startRange.equals(Range.all())) {
        startRange = startRange.intersection(weakStartRange);
    } else if (!weakStartRange.equals(Range.all())) {
        startRange = weakStartRange.intersection(subtreeStartUpwards);
    }
    if (!endRange.equals(Range.all())) {
        endRange = endRange.intersection(weakEndRange);
    } else if (!weakEndRange.equals(Range.all())) {
        endRange = weakEndRange.intersection(subtreeEndDownwards);
    }
    if (node.getTask().getThirdDateConstraint() == TaskImpl.EARLIESTBEGIN
            && node.getTask().getThird() != null) {
        startRange = startRange
                .intersection(Range.downTo(node.getTask().getThird().getTime(), BoundType.CLOSED));
        GPLogger.debug(logger, ".. applying earliest start=%s. Now start range=%s", node.getTask().getThird(),
                startRange);
    }
    if (!subtaskRanges.isEmpty()) {
        startRange = startRange.intersection(subtasksSpan);
        endRange = endRange.intersection(subtasksSpan);
    }
    GPLogger.debug(logger, ".. finally, start range=%s", startRange);
    if (startRange.hasLowerBound()) {
        modifyTaskStart(node.getTask(), startRange.lowerEndpoint());
    }
    if (endRange.hasUpperBound()) {
        GPCalendarCalc cal = node.getTask().getManager().getCalendar();
        Date endDate = endRange.upperEndpoint();
        TimeUnit timeUnit = node.getTask().getDuration().getTimeUnit();
        if (DayMask.WORKING == (cal.getDayMask(endDate) & DayMask.WORKING)) {
            // in case if calculated end date falls on first day after holidays (say, on Monday)
            // we'll want to modify it a little bit, so that it falls on that holidays start
            // If we don't do this, it will be done automatically the next time task activities are recalculated,
            // and thus task end date will keep changing
            Date closestWorkingEndDate = cal.findClosest(endDate, timeUnit,
                    GPCalendarCalc.MoveDirection.BACKWARD, GPCalendar.DayType.WORKING);
            Date closestNonWorkingEndDate = cal.findClosest(endDate, timeUnit,
                    GPCalendarCalc.MoveDirection.BACKWARD, GPCalendar.DayType.NON_WORKING,
                    closestWorkingEndDate);
            // If there is a non-working date between current task end and closest working date
            // then we're really just after holidays
            if (closestNonWorkingEndDate != null && closestWorkingEndDate.before(closestNonWorkingEndDate)) {
                // we need to adjust-right closest working date to position to the very beginning of the holidays interval
                Date nonWorkingPeriodStart = timeUnit.adjustRight(closestWorkingEndDate);
                if (nonWorkingPeriodStart.after(node.getTask().getStart().getTime())) {
                    endDate = nonWorkingPeriodStart;
                }
            }
        }
        modifyTaskEnd(node.getTask(), endDate);
    }
}