Example usage for com.google.common.collect ArrayListMultimap create

List of usage examples for com.google.common.collect ArrayListMultimap create

Introduction

In this page you can find the example usage for com.google.common.collect ArrayListMultimap create.

Prototype

public static <K, V> ArrayListMultimap<K, V> create() 

Source Link

Document

Creates a new, empty ArrayListMultimap with the default initial capacities.

Usage

From source file:com.dotweblabs.friendscube.app.client.local.widgets.connections.FriendsPageItem.java

@EventHandler("userFullName")
public void viewFriend(ClickEvent event) {
    event.preventDefault();//from  www  . j  a v  a  2s. c  o m
    Multimap<String, String> state = ArrayListMultimap.create();
    state.put("friend", String.valueOf(profile.getUserId()));
    friendFeedsPage.go(state);
}

From source file:org.jenkinsci.plugins.all_changes.AllChangesAction.java

/**
 * Returns all changes which contribute to a build.
 *
 * @param build/*from  w  w  w. j av a  2s  .c om*/
 * @return
 */
public Multimap<ChangeLogSet.Entry, AbstractBuild> getAllChanges(AbstractBuild build) {
    Set<AbstractBuild> builds = getContributingBuilds(build);
    Multimap<String, ChangeLogSet.Entry> changes = ArrayListMultimap.create();
    for (AbstractBuild changedBuild : builds) {
        ChangeLogSet<ChangeLogSet.Entry> changeSet = changedBuild.getChangeSet();
        for (ChangeLogSet.Entry entry : changeSet) {
            changes.put(entry.getCommitId() + entry.getMsgAnnotated() + entry.getTimestamp(), entry);
        }
    }
    Multimap<ChangeLogSet.Entry, AbstractBuild> change2Build = HashMultimap.create();
    for (String changeKey : changes.keySet()) {
        ChangeLogSet.Entry change = changes.get(changeKey).iterator().next();
        for (ChangeLogSet.Entry entry : changes.get(changeKey)) {
            change2Build.put(change, entry.getParent().build);
        }
    }
    return change2Build;
}

From source file:com.viadeo.kasper.core.id.ConverterRegistry.java

public void register(Converter converter) {
    checkNotNull(converter);/*from w w  w .  ja v  a2 s. c  om*/

    Multimap<Format, Converter> currentConvertersByFormats = currentConvertersByFormatsByVendors
            .get(converter.getVendor());

    if (currentConvertersByFormats == null) {
        currentConvertersByFormats = ArrayListMultimap.create();
        currentConvertersByFormatsByVendors.put(converter.getVendor(), currentConvertersByFormats);
    }

    currentConvertersByFormats.put(converter.getTarget(), converter);
}

From source file:org.clueminer.eval.utils.Matching.java

/**
 * Allows searching in map by value, a cluster might be mapped to multiple
 * classes//  w  ww .  j  a v  a  2 s .  c  om
 *
 * @return
 */
public Multimap<String, String> inverse() {
    Multimap<String, String> multi = ArrayListMultimap.create();
    for (Map.Entry<String, String> e : matching.entrySet()) {
        multi.put(e.getValue(), e.getKey());
    }
    inverse = multi;
    return multi;
}

From source file:org.jenkinsci.plugins.all_changes.AllChangesWorkflowAction.java

/**
 * Returns all changes which contribute to a build.
 *
 * @param build//from w  w w .j a v  a2s  .  c o  m
 * @return
 */
public Multimap<ChangeLogSet.Entry, WorkflowRun> getAllChanges(WorkflowRun build) {
    Set<WorkflowRun> builds = getContributingBuilds(build);
    Multimap<String, ChangeLogSet.Entry> changes = ArrayListMultimap.create();
    for (WorkflowRun changedBuild : builds) {
        for (ChangeLogSet changeLogSet : changedBuild.getChangeSets()) {
            ChangeLogSet<ChangeLogSet.Entry> changeSet = (ChangeLogSet<ChangeLogSet.Entry>) changeLogSet;
            for (ChangeLogSet.Entry entry : changeSet) {
                changes.put(entry.getCommitId() + entry.getMsgAnnotated() + entry.getTimestamp(), entry);
            }
        }
    }
    Multimap<ChangeLogSet.Entry, WorkflowRun> change2Build = HashMultimap.create();
    for (String changeKey : changes.keySet()) {
        ChangeLogSet.Entry change = changes.get(changeKey).iterator().next();
        for (ChangeLogSet.Entry entry : changes.get(changeKey)) {
            change2Build.put(change, (WorkflowRun) entry.getParent().getRun());
        }
    }
    return change2Build;
}

From source file:com.proofpoint.jmx.JmxInspector.java

@Inject
public JmxInspector(Injector injector) throws Exception {
    MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    Set<ObjectInstance> instances = mBeanServer.queryMBeans(null, null);
    Multimap<String, String> nameMap = ArrayListMultimap.create();
    for (ObjectInstance i : instances) {
        nameMap.put(i.getClassName(), i.getObjectName().getCanonicalName());
    }//from www .j  av  a 2s .  c o  m

    ImmutableSortedSet.Builder<InspectorRecord> builder = ImmutableSortedSet.naturalOrder();
    GuiceInjectorIterator injectorIterator = new GuiceInjectorIterator(injector);
    for (Class<?> clazz : injectorIterator) {
        addConfig(nameMap, clazz, builder);
    }

    inspectorRecords = builder.build();
}

From source file:org.onehippo.cms7.essentials.dashboard.instruction.executors.MessageInstructionExecutor.java

@SuppressWarnings("InstanceofInterfaces")
public Multimap<MessageGroup, Restful> execute(final InstructionSet instructionSet, PluginContext context) {

    final Multimap<MessageGroup, Restful> retVal = ArrayListMultimap.create();
    final Map<String, Object> placeholderData = context.getPlaceholderData();

    final Set<Instruction> mySet = instructionSet.getInstructions();
    for (Instruction instruction : mySet) {
        if (instruction instanceof FreemarkerInstruction) {
            processFreemarkerInstruction(retVal, placeholderData, (FreemarkerInstruction) instruction);
        } else if (instruction instanceof FileInstruction) {
            processFileInstruction(retVal, placeholderData, (FileInstruction) instruction);

        } else if (instruction instanceof NodeFolderInstruction) {
            processFolderInstruction(retVal, placeholderData, (NodeFolderInstruction) instruction);
        } else if (instruction instanceof CndInstruction) {
            processCndInstruction(retVal, placeholderData, (CndInstruction) instruction);
        } else if (instruction instanceof XmlInstruction) {
            processXmlInstruction(retVal, placeholderData, (XmlInstruction) instruction);
        } else if (instruction instanceof ExecuteInstruction) {
            processXmlInstruction(retVal, placeholderData, (ExecuteInstruction) instruction);
        } else {/*  ww  w.  jav a2 s  .  co m*/
            retVal.put(MessageGroup.UNKNOWN, new MessageRestful(instruction.getMessage()));
        }
    }

    return retVal;
}

From source file:gobblin.util.PublisherUtils.java

/**
 * Given a {@link Multimap} of {@link Extract}s to {@link WorkUnitState}s, filter out any {@link Extract}s where all
 * of the corresponding {@link WorkUnitState}s do not meet the given {@link Predicate}.
 * <ul>//from  w ww  .  jav a 2  s . c o m
 *  <li> The filtered {@link Extract}s will be available in {@link SplitExtractsResult#getFiltered()}</li>
 *  <li> The {@link Extract}s satisfying the predicated will be available in {@link SplitExtractsResult#getRetained()}</li>
 * </ul>
 *
 */
public static SplitExtractsResult splitExtractsByPredicate(
        Multimap<Extract, WorkUnitState> extractToWorkUnitStateMap, Predicate<WorkUnitState> predicate) {
    Multimap<Extract, WorkUnitState> retained = ArrayListMultimap.create();
    Multimap<Extract, WorkUnitState> filtered = ArrayListMultimap.create();
    for (Map.Entry<Extract, Collection<WorkUnitState>> entry : extractToWorkUnitStateMap.asMap().entrySet()) {
        if (Iterables.all(entry.getValue(), predicate)) {
            retained.putAll(entry.getKey(), entry.getValue());
        } else {
            filtered.putAll(entry.getKey(), entry.getValue());
        }
    }
    return new SplitExtractsResult(retained, filtered);
}

From source file:it.units.malelab.ege.distributed.worker.Worker.java

public Worker(String keyPhrase, InetAddress masterAddress, int masterPort, int nThreads,
        String logDirectoryName) {
    this.keyPhrase = keyPhrase;
    this.masterAddress = masterAddress;
    this.masterPort = masterPort;
    this.maxThreads = nThreads;
    comExecutor = Executors.newSingleThreadScheduledExecutor();
    taskExecutor = Executors.newFixedThreadPool(nThreads);
    runExecutor = Executors.newCachedThreadPool();
    currentJobsData = (Multimap) Multimaps.synchronizedMultimap(ArrayListMultimap.create());
    currentJobs = Collections.synchronizedSet(new HashSet<Job>());
    completedJobsResults = Collections.synchronizedMap(new HashMap<Job, List<Node>>());
    stats = (Multimap) Multimaps.synchronizedMultimap(ArrayListMultimap.create());
    name = ManagementFactory.getRuntimeMXBean().getName();
    interval = MASTER_INTERVAL;/*from w w w .  j a va2  s.  c  o m*/
    printStreamFactory = new PrintStreamFactory(logDirectoryName);
}

From source file:com.android.tools.idea.gradle.service.ProjectImportEventMessageDataService.java

@Override
public void importData(@NotNull Collection<DataNode<ProjectImportEventMessage>> toImport,
        @NotNull final Project project, boolean synchronous) {
    final ExternalSystemIdeNotificationManager notificationManager = ServiceManager
            .getService(ExternalSystemIdeNotificationManager.class);
    if (notificationManager == null) {
        return;//from w  w w  . jav a 2 s . com
    }

    Multimap<String, String> messagesByCategory = ArrayListMultimap.create();
    for (DataNode<ProjectImportEventMessage> node : toImport) {
        ProjectImportEventMessage message = node.getData();
        String category = message.getCategory();
        messagesByCategory.put(category, message.getText());
        LOG.info(message.toString());
    }
    final StringBuilder builder = new StringBuilder();
    builder.append("<html>");
    for (String category : messagesByCategory.keySet()) {
        Collection<String> messages = messagesByCategory.get(category);
        if (category.isEmpty()) {
            Joiner.on("<br>").join(messages);
        } else {
            // If the category is not an empty String, we show the category and each message as a list.
            builder.append(category).append("<ul>");
            for (String message : messages) {
                builder.append("<li>").append(message).append("</li>");
            }
            builder.append("</ul>");
        }
    }
    builder.append("</html>");

    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            String title = "Unexpected events:";
            String messageToShow = builder.toString();
            notificationManager.showNotification(title, messageToShow, NotificationType.ERROR, project,
                    GradleConstants.SYSTEM_ID, null);
        }
    });
}