Example usage for com.google.common.collect SetMultimap isEmpty

List of usage examples for com.google.common.collect SetMultimap isEmpty

Introduction

In this page you can find the example usage for com.google.common.collect SetMultimap isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this multimap contains no key-value pairs.

Usage

From source file:com.addthis.hydra.query.MeshFileRefCache.java

/**
 * This method filters the file references to ensure that only valid file references are returned.
 * <p/>/*from   w w w  .  j a  v  a  2 s . c  om*/
 * The filter checks for two things.
 * <p/>
 * <ol>
 * <li>the last modified date for each file for the same task should be the same, if not it will take the
 * newest file</li>
 * <li>the size of the files should be equal, if not, take the files with the largest known size</li>
 * </ol>
 *
 * @param fileRefDataSet - the original unfiltered file reference set
 * @return - filtered file reference map containing only valid file references
 */
@Nonnull
protected static SetMultimap<Integer, FileReference> filterFileReferences(
        @Nonnull SetMultimap<Integer, FileReference> fileRefDataSet) {
    if (fileRefDataSet.isEmpty()) {
        return fileRefDataSet;
    }
    int baseKeySetSize = fileRefDataSet.keySet().size();
    SetMultimap<Integer, FileReference> filteredFileReferenceSet = HashMultimap.create(baseKeySetSize,
            fileRefDataSet.size() / baseKeySetSize);
    for (Map.Entry<Integer, Collection<FileReference>> entry : fileRefDataSet.asMap().entrySet()) {
        int key = entry.getKey();
        final Collection<FileReference> fileReferences = entry.getValue();
        long mostRecentTime = -1;

        for (FileReference fileReference : fileReferences) {
            if ((mostRecentTime < 0) || (fileReference.lastModified > mostRecentTime)) {
                mostRecentTime = fileReference.lastModified;
            }
        }

        final long mostRecentTimeF = mostRecentTime;
        Predicate<FileReference> isMostRecent = input -> (input != null)
                && (input.lastModified == mostRecentTimeF);

        Collection<FileReference> filteredFileReferences = Collections2.filter(fileReferences, isMostRecent);
        filteredFileReferenceSet.putAll(key, filteredFileReferences);
    }
    return filteredFileReferenceSet;
}

From source file:org.eclipse.gef4.zest.fx.policies.HoverFirstAnchorageOnHoverPolicy.java

@Override
public void hover(MouseEvent e) {
    SetMultimap<IVisualPart<Node, ? extends Node>, String> anchorages = getHost().getAnchorages();
    if (anchorages == null || anchorages.isEmpty()) {
        return;/*from   w  ww.j  av a2 s  .  c o  m*/
    }
    getHost().getRoot().getViewer().<HoverModel<Node>>getAdapter(HoverModel.class)
            .setHover(anchorages.keySet().iterator().next());
}

From source file:org.eclipse.gef4.zest.fx.policies.HideFirstAnchorageOnClickPolicy.java

@Override
public void click(MouseEvent e) {
    SetMultimap<IVisualPart<Node, ? extends Node>, String> anchorages = getHost().getAnchorages();
    if (anchorages == null || anchorages.isEmpty()) {
        return;/*from w  w  w  .  ja va 2 s  . c  om*/
    }
    IVisualPart<Node, ? extends Node> anchorage = anchorages.keySet().iterator().next();
    HidePolicy hideNodePolicy = anchorage.getAdapter(HidePolicy.class);
    init(hideNodePolicy);
    hideNodePolicy.hide();
    commit(hideNodePolicy);
}

From source file:org.eclipse.gef4.zest.fx.policies.ShowHiddenNeighborsOfFirstAnchorageOnClickPolicy.java

@Override
public void click(MouseEvent e) {
    SetMultimap<IVisualPart<Node, ? extends Node>, String> anchorages = getHost().getAnchorages();
    if (anchorages == null || anchorages.isEmpty()) {
        return;/*from w w  w .j a va 2s.  c o  m*/
    }
    IVisualPart<Node, ? extends Node> anchorage = anchorages.keySet().iterator().next();
    ShowHiddenNeighborsPolicy hiddenNeighborsPolicy = anchorage.getAdapter(ShowHiddenNeighborsPolicy.class);
    init(hiddenNeighborsPolicy);
    hiddenNeighborsPolicy.showHiddenNeighbors();
    commit(hiddenNeighborsPolicy);
}

From source file:org.eclipse.gef4.mvc.examples.logo.parts.FXHoverHandleRootPart.java

@Override
protected void doRefreshVisual(VBox visual) {
    // check if we have a host
    SetMultimap<IVisualPart<Node, ? extends Node>, String> anchorages = getAnchorages();
    if (anchorages.isEmpty()) {
        return;/*  ww w . ja  v  a2s . c  om*/
    }

    // determine center location of host visual
    IVisualPart<Node, ? extends Node> anchorage = anchorages.keys().iterator().next();
    refreshHandleLocation(anchorage.getVisual());
}

From source file:info.nemoworks.airsys.policies.FXDeleteFirstAnchorageOnClickPolicy.java

@Override
public IVisualPart<Node, ? extends Node> getHost() {
    SetMultimap<IVisualPart<Node, ? extends Node>, String> anchorages = super.getHost().getParent()
            .getAnchorages();/*from w  ww. j  ava 2s .com*/
    if (anchorages == null || anchorages.isEmpty()) {
        return null;
    }
    return anchorages.keySet().iterator().next();
}

From source file:org.eclipse.gef4.mvc.examples.logo.rcp.parts.FXHoverHandleRootPart.java

@Override
protected void doRefreshVisual(VBox visual) {
    // check if we have a host
    SetMultimap<IVisualPart<Node, ? extends Node>, String> anchorages = getAnchoragesUnmodifiable();
    if (anchorages.isEmpty()) {
        return;/*from ww  w. ja  v  a 2  s  .c om*/
    }

    // determine center location of host visual
    IVisualPart<Node, ? extends Node> anchorage = anchorages.keys().iterator().next();
    refreshHandleLocation(anchorage.getVisual());
}

From source file:org.eclipse.gef4.zest.fx.parts.ZestFxHidingHandlePart.java

protected void onClicked(MouseEvent event) {
    SetMultimap<IVisualPart<Node, ? extends Node>, String> anchorages = getAnchorages();
    if (anchorages == null || anchorages.isEmpty()) {
        return;//from   ww w .  j a va2s . c o  m
    }
    IVisualPart<Node, ? extends Node> anchorage = anchorages.keySet().iterator().next();
    HideNodePolicy hideNodePolicy = anchorage.getAdapter(HideNodePolicy.class);
    hideNodePolicy.hide();
}

From source file:checkers.game_engine.game_rules.RuleManager.java

@Override
public SetMultimap<Position, Position> getAllAvailableMoves(Player activePlayer, Board board) {
    SetMultimap<Position, Position> allMoves = getAllAvailableCaptures(activePlayer, board);
    if (!allMoves.isEmpty()) {
        return allMoves;
    }/*  ww w. j a v a 2s.  c  o  m*/

    for (int i = 1; i < board.getSize(); i++) {
        for (int j = 1; j < board.getSize(); j++) {
            Position startPos = new Position(i, j);

            if (activePlayer == Player.PLAYER_ONE && (board.getFieldAt(i, j) == Board.WHITE_KING
                    || board.getFieldAt(i, j) == Board.WHITE_REGULAR_PIECE)) {
                allMoves.putAll(startPos, getAvailableMoves(startPos, board));
            } else if (activePlayer == Player.PLAYER_TWO && (board.getFieldAt(i, j) == Board.BLACK_KING
                    || board.getFieldAt(i, j) == Board.BLACK_REGULAR_PIECE)) {
                allMoves.putAll(startPos, getAvailableMoves(startPos, board));
            }
        }
    }
    return allMoves;
}

From source file:com.google.devtools.build.lib.query2.output.ConditionalEdges.java

/** Builds ConditionalEdges from given graph. */
public ConditionalEdges(Digraph<Target> graph) {
    this.map = new HashMap<>();

    for (Node<Target> node : graph.getNodes()) {
        Rule rule = node.getLabel().getAssociatedRule();
        if (rule == null) {
            // rule is null for source files and package groups. Skip them.
            continue;
        }// w w w  .j a  va 2  s  .  c  om

        SetMultimap<Label, Label> conditions = getAllConditions(rule, RawAttributeMapper.of(rule));
        if (conditions.isEmpty()) {
            // bail early for most common case of no conditions in the rule.
            continue;
        }

        Label nodeLabel = node.getLabel().getLabel();
        for (Node<Target> succ : node.getSuccessors()) {
            Label successorLabel = succ.getLabel().getLabel();
            if (conditions.containsKey(successorLabel)) {
                insert(nodeLabel, successorLabel, conditions.get(successorLabel));
            }
        }
    }
}