Example usage for com.google.common.collect Multimap get

List of usage examples for com.google.common.collect Multimap get

Introduction

In this page you can find the example usage for com.google.common.collect Multimap get.

Prototype

Collection<V> get(@Nullable K key);

Source Link

Document

Returns a view collection of the values associated with key in this multimap, if any.

Usage

From source file:co.cask.cdap.cli.docs.GenerateCLIDocsTableCommand.java

@Override
public void execute(Arguments arguments, PrintStream output) throws Exception {
    Multimap<String, Command> categorizedCommands = categorizeCommands(commands.get(), CommandCategory.GENERAL,
            Predicates.<Command>alwaysTrue());
    for (CommandCategory category : CommandCategory.values()) {
        output.printf("   **%s**\n", simpleTitleCase(category.getName()));
        List<Command> commandList = Lists.newArrayList(categorizedCommands.get(category.getName()));
        Collections.sort(commandList, new Comparator<Command>() {
            @Override//from  w w w  .  j  a  v  a 2 s  .co m
            public int compare(Command command, Command command2) {
                return command.getPattern().compareTo(command2.getPattern());
            }
        });
        for (Command command : commandList) {
            output.printf("   ``%s``,\"%s\"\n", command.getPattern(),
                    command.getDescription().replace("\"", "\"\""));
        }
    }
}

From source file:com.github.jcustenborder.kafka.connect.utils.templates.model.Configuration.java

private Configuration(Collection<Item> configs) {
    this.requiredConfigs = configs.stream().filter(Item::isRequired).collect(Collectors.toList());

    Multimap<String, Item> groupToItem = LinkedListMultimap.create();
    for (Item item : configs) {
        groupToItem.put(item.group, item);
    }/*  w  w  w. ja  v  a2  s  .  co m*/
    List<Group> groups = new ArrayList<>();
    for (String group : groupToItem.keySet()) {
        Collection<Item> items = groupToItem.get(group);
        groups.add(new Group(group, new ArrayList<>(items)));
    }
    Collections.sort(groups);

    this.groups = ImmutableList.copyOf(groups);
}

From source file:org.sonar.plugins.core.notifications.violations.NewViolationsOnMyFavouriteProject.java

@Override
public void dispatch(Notification notification, Context context) {
    // "null" is passed as a 2nd argument because this dispatcher is not a per-project dispatcher
    Multimap<String, NotificationChannel> subscribedRecipients = notificationManager
            .findSubscribedRecipientsForDispatcher(this, null);

    List<String> userLogins = propertiesDao
            .findUserIdsForFavouriteResource(Long.parseLong(notification.getFieldValue("projectId")));
    for (String userLogin : userLogins) {
        Collection<NotificationChannel> channels = subscribedRecipients.get(userLogin);
        for (NotificationChannel channel : channels) {
            context.addUser(userLogin, channel);
        }//  w w w  .  j  a  v a  2  s .c o m
    }
}

From source file:com.synflow.cx.ui.internal.views.fsm.layout.EdgeLayout.java

private void layoutDoubleEdges(List<State> states) {
    for (State state : states) {
        Multimap<State, Transition> map = HashMultimap.create();
        for (Edge edge : state.getOutgoing()) {
            map.put((State) edge.getTarget(), (Transition) edge);
        }/* w ww .j a  va2 s  .  c o  m*/

        for (State target : map.keySet()) {
            Collection<Transition> transitions = map.get(target);
            if (transitions.size() >= 2) {
                Point l1 = state.get("location");
                Point l2 = target.get("location");

                int inc = BREADTH / (transitions.size() - 1);
                int x = (l1.x + l2.x) / 2 - BREADTH / 2 + 15;
                final int y = (l1.y + l2.y + 20) / 2;

                for (Transition transition : transitions) {
                    List<Bendpoint> bendpoints = new ArrayList<>();
                    AbsoluteBendpoint bp;
                    bp = new AbsoluteBendpoint(x, y - 5);
                    bendpoints.add(bp);

                    bp = new AbsoluteBendpoint(x, y + 5);
                    bendpoints.add(bp);

                    setBendpoints(transition, bendpoints);
                    x += inc;
                }
            }
        }
    }
}

From source file:de.metas.ui.web.window.descriptor.DocumentFieldDependencyMap.java

public void consumeForChangedFieldName(final String changedFieldName, final IDependencyConsumer consumer) {
    for (final DependencyType dependencyType : DependencyType.values()) {
        final Multimap<String, String> name2dependencies = type2name2dependencies.get(dependencyType);
        if (name2dependencies == null || name2dependencies.isEmpty()) {
            continue;
        }//from   www.  j a va  2  s  .c  o m

        for (final String dependentFieldName : name2dependencies.get(changedFieldName)) {
            consumer.consume(dependentFieldName, dependencyType);
        }
    }
}

From source file:org.sosy_lab.cpachecker.core.algorithm.invariants.LazyLocationMapping.java

public Iterable<AbstractState> get0(CFANode pLocation) {
    if (reachedSet instanceof LocationMappedReachedSet) {
        return AbstractStates.filterLocation(reachedSet, pLocation);
    }// ww  w  . java2s.  co m
    if (statesByLocationRef.get() == null) {
        Multimap<CFANode, AbstractState> statesByLocation = HashMultimap.create();
        for (AbstractState state : reachedSet) {
            for (CFANode location : AbstractStates.extractLocations(state)) {
                statesByLocation.put(location, state);
            }
        }
        this.statesByLocationRef.set(statesByLocation);
        return statesByLocation.get(pLocation);
    }
    return statesByLocationRef.get().get(pLocation);
}

From source file:org.sosy_lab.cpachecker.cpa.constraints.refiner.precision.ConstraintBasedConstraintsPrecision.java

private boolean constraintWithSameMeaningExists(final CFANode pLoc, final Constraint pConstraint,
        final Multimap<CFANode, Constraint> pTrackedConstraints) {

    if (pTrackedConstraints.containsKey(pLoc)) {
        final Collection<Constraint> constraintsOnLocation = pTrackedConstraints.get(pLoc);

        for (Constraint c : constraintsOnLocation) {
            if (SymbolicValues.representSameCCodeExpression(c, pConstraint)) {
                return true;
            }//w  w w. ja  va  2 s .c o  m
        }
    }

    return false;
}

From source file:io.bazel.rules.closure.webfiles.WebfilesValidatorProgram.java

private int displayErrors(Set<String> suppress, Multimap<String, String> errors) {
    int exitCode = 0;
    for (String category : errors.keySet()) {
        boolean ignored = suppress.contains(category) || suppress.contains(SUPPRESS_EVERYTHING);
        String prefix = ignored ? WARNING_PREFIX : ERROR_PREFIX;
        for (String error : errors.get(category)) {
            output.println(prefix + error);
        }/*from  w  ww .j a va  2  s  .com*/
        if (!ignored) {
            exitCode = 1;
            output.printf("%sUse suppress=[\"%s\"] to make the errors above warnings%n", NOTE_PREFIX, category);
        }
    }
    return exitCode;
}

From source file:nl.knaw.huygens.alexandria.dropwizard.cli.commands.AlexandriaCommand.java

void showChanges(Multimap<FileStatus, String> fileStatusMap) {
    AnsiConsole.systemInstall();//ww w  .  j a v  a  2  s .c o  m

    Set<String> changedFiles = new HashSet<>(fileStatusMap.get(FileStatus.changed));
    Set<String> deletedFiles = new HashSet<>(fileStatusMap.get(FileStatus.deleted));
    if (!(changedFiles.isEmpty() && deletedFiles.isEmpty())) {
        System.out.printf("Uncommitted changes:%n"
                + "  (use \"alexandria commit <file>...\" to commit the selected changes)%n"
                + "  (use \"alexandria commit -a\" to commit all changes)%n"
                + "  (use \"alexandria revert <file>...\" to discard changes)%n%n");
        Set<String> changedOrDeletedFiles = new TreeSet<>();
        changedOrDeletedFiles.addAll(changedFiles);
        changedOrDeletedFiles.addAll(deletedFiles);
        changedOrDeletedFiles.forEach(file -> {
            String status = changedFiles.contains(file) ? "        modified: " : "        deleted:  ";
            System.out.println(ansi().fg(RED).a(status).a(file).reset());
        });
    }

    Collection<String> createdFiles = fileStatusMap.get(FileStatus.created);
    if (!createdFiles.isEmpty()) {
        System.out.printf(
                "Untracked files:%n" + "  (use \"alexandria add <file>...\" to start tracking this file.)%n%n");
        createdFiles.stream().sorted()
                .forEach(f -> System.out.println(ansi().fg(RED).a("        ").a(f).reset()));
    }

    AnsiConsole.systemUninstall();
}

From source file:org.sonar.batch.source.SymbolData.java

@Override
public String writeString() {
    StringBuilder sb = new StringBuilder();

    Multimap<Symbol, Integer> referencesBySymbol = ((DefaultSymbolTable) symbolTable).getReferencesBySymbol();

    for (Symbol symbol : ((DefaultSymbolTable) symbolTable).getReferencesBySymbol().keySet()) {

        sb.append(symbol.getDeclarationStartOffset()).append(FIELD_SEPARATOR)
                .append(symbol.getDeclarationEndOffset());
        Collection<Integer> symbolReferences = referencesBySymbol.get(symbol);
        for (Integer symbolReference : symbolReferences) {
            sb.append(FIELD_SEPARATOR).append(symbolReference);
        }/* w ww .  ja v a  2  s .  c  o m*/
        sb.append(SYMBOL_SEPARATOR);
    }

    return sb.toString();
}