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:org.rf.ide.core.testdata.model.table.RobotElementsComparatorWithPositionChangedPresave.java

public Multimap<IRobotLineElement, Integer> indexesOf(final Collection<IRobotLineElement> list,
        final IRobotLineElement... elements) {
    final List<IRobotLineElement> elems = new ArrayList<>(Arrays.asList(elements));
    final Multimap<IRobotLineElement, Integer> found = ArrayListMultimap.create();
    final int listSize = list.size();
    for (int i = 0; i < listSize; i++) {
        for (final IRobotLineElement e : elems) {
            if (e == list.toArray()[i]) {
                found.put(e, i);/* w  w w.  j  a  v  a2  s .c  o m*/
            }
        }
    }

    return found;
}

From source file:net.brtly.monkeyboard.plugin.core.PluginManager.java

public PluginManager(EventBus eventBus) {
    _delegates = new HashMap<String, DelegateLoader>();
    _plugins = new HashMap<String, PluginLoader>();
    _pluginTable = ArrayListMultimap.create();

    _eventBus = eventBus;/* w w  w. j a va 2  s  .c o  m*/

    LOG.debug("PluginManager initialized");
}

From source file:com.mgmtp.jfunk.core.mail.MailMessage.java

private static ListMultimap<RecipientType, String> createRecipients(final Message message)
        throws MessagingException {
    ListMultimap<RecipientType, String> recipients = ArrayListMultimap.create();

    for (javax.mail.Message.RecipientType recipientType : asList(javax.mail.Message.RecipientType.TO,
            javax.mail.Message.RecipientType.CC, javax.mail.Message.RecipientType.BCC)) {
        Address[] addresses = message.getRecipients(recipientType);
        if (addresses != null) {
            for (Address address : addresses) {
                recipients.put(RecipientType.valueOf(recipientType.toString()), address.toString());
            }// ww w. j  av a  2 s  . co  m
        }
    }

    return recipients;
}

From source file:org.sonar.batch.rule.ActiveRulesProvider.java

private ActiveRules load(ModuleQProfiles qProfiles, ActiveRuleDao dao, RuleFinder ruleFinder) {
    ActiveRulesBuilder builder = new ActiveRulesBuilder();
    for (ModuleQProfiles.QProfile qProfile : qProfiles.findAll()) {
        ListMultimap<Integer, ActiveRuleParamDto> paramDtosByActiveRuleId = ArrayListMultimap.create();
        for (ActiveRuleParamDto dto : dao.selectParamsByProfileId(qProfile.id())) {
            paramDtosByActiveRuleId.put(dto.getActiveRuleId(), dto);
        }//from  www .ja  va2  s  .  com

        for (ActiveRuleDto activeDto : dao.selectByProfileId(qProfile.id())) {
            Rule rule = ruleFinder.findById(activeDto.getRulId());
            if (rule != null) {
                NewActiveRule newActiveRule = builder.activate(rule.ruleKey());
                newActiveRule.setSeverity(activeDto.getSeverityString());
                if (rule.getParent() != null) {
                    newActiveRule.setInternalKey(rule.getParent().getConfigKey());
                } else {
                    newActiveRule.setInternalKey(rule.getConfigKey());
                }

                // load parameter values
                for (ActiveRuleParamDto paramDto : paramDtosByActiveRuleId.get(activeDto.getId())) {
                    newActiveRule.setParam(paramDto.getKey(), paramDto.getValue());
                }

                // load default values
                for (RuleParam param : rule.getParams()) {
                    if (!newActiveRule.params().containsKey(param.getKey())) {
                        newActiveRule.setParam(param.getKey(), param.getDefaultValue());
                    }
                }
            }
        }
    }
    return builder.build();
}

From source file:org.opentestsystem.delivery.testreg.service.impl.MockTestRegUserDetailsServiceImpl.java

@Override
public SbacUser getCurrentUser() {
    Multimap<String, SbacRole> roles = ArrayListMultimap.create();
    return new SbacUser(roles, null);
}

From source file:org.xenmaster.monitoring.MonitoringAgent.java

private MonitoringAgent() {
    vmData = ArrayListMultimap.create();
    hostData = ArrayListMultimap.create();
    data = new ConcurrentSkipListMap<>();
    NTPUDPClient nuc = new NTPUDPClient();
    ringBuffer = new RingBuffer<>(Record.EVENT_FACTORY, new SingleThreadedClaimStrategy(RING_SIZE),
            new BlockingWaitStrategy());
    eventHandler = new EventHandler();
    comptroller = new Comptroller();
    emitter = new Emitter();
    collector = new Collector();
    correl = new Correlator();

    setUpEngine();/*w w w.j  a v a  2  s.  co  m*/

    try {
        timeInfo = nuc.getTime(InetAddress.getByName(NTP_SERVER));
        timeInfo.computeDetails();
        Logger.getLogger(getClass())
                .info("Current time "
                        + new DateTime(System.currentTimeMillis() + timeInfo.getOffset())
                                .toString("dd/MM/yyyy HH:mm:ss.S")
                        + ". Clock drift " + timeInfo.getOffset() + " milliseconds");
    } catch (IOException ex) {
        Logger.getLogger(getClass()).warn("NTP time retrieval failed", ex);
    }
}

From source file:ch.ethz.bsse.quasirecomb.informationholder.ModelSelectionStorage.java

public Multimap<Integer, Double> getMaxBICs() {
    Multimap<Integer, Double> bics = ArrayListMultimap.create();
    for (Map.Entry<Integer, SelectionResult> entry : srMap.entrySet()) {
        SelectionResult srTmp = entry.getValue();
        bics.put(entry.getKey(), srTmp.max);
    }//from   w  w  w.j  a va 2s. co  m
    return bics;
}

From source file:org.jetbrains.kotlin.util.slicedMap.SlicedMapImpl.java

@Override
public <K, V> void put(WritableSlice<K, V> slice, K key, V value) {
    if (!slice.check(key, value)) {
        return;//w  w  w.  ja v  a 2 s .  c  o m
    }

    UserDataHolderImpl holder = map.get(key);
    if (holder == null) {
        holder = new UserDataHolderImpl();
        map.put(key, holder);
    }

    Key<V> sliceKey = slice.getKey();

    RewritePolicy rewritePolicy = slice.getRewritePolicy();
    if (rewritePolicy.rewriteProcessingNeeded(key)) {
        V oldValue = holder.getUserData(sliceKey);
        if (oldValue != null) {
            //noinspection unchecked
            if (!rewritePolicy.processRewrite(slice, key, oldValue, value)) {
                return;
            }
        }
    }

    if (slice.isCollective()) {
        if (collectiveSliceKeys == null) {
            collectiveSliceKeys = ArrayListMultimap.create();
        }

        collectiveSliceKeys.put(slice, key);
    }

    holder.putUserData(sliceKey, value);
    slice.afterPut(this, key, value);
}

From source file:de.bund.bfr.knime.gis.views.canvas.RegionCanvasUtils.java

public static void paintRegions(Graphics2D g, Collection<RegionNode> nodes, Set<RegionNode> selectedNodes,
        HighlightConditionList nodeHighlightConditions) {
    Paint currentPaint = g.getPaint();

    g.setPaint(Color.BLUE);//from w ww . ja v  a 2 s.  c o  m
    selectedNodes.forEach(n -> g.fill(n.getTransformedPolygon()));

    List<Color> nodeColors = new ArrayList<>();
    ListMultimap<RegionNode, Double> nodeAlphas = ArrayListMultimap.create();
    boolean prioritize = nodeHighlightConditions.isPrioritizeColors();

    for (HighlightCondition condition : nodeHighlightConditions.getConditions()) {
        Map<RegionNode, Double> values = condition.getValues(nodes);

        if (condition.getColor() != null) {
            nodeColors.add(condition.getColor());

            for (RegionNode node : nodes) {
                List<Double> alphas = nodeAlphas.get(node);

                if (!prioritize || alphas.isEmpty() || Collections.max(alphas) == 0.0) {
                    alphas.add(values.get(node));
                } else {
                    alphas.add(0.0);
                }
            }
        }
    }

    for (RegionNode node : nodes) {
        Paint color = CanvasUtils.mixColors(Color.WHITE, nodeColors, nodeAlphas.get(node), false);

        if (!color.equals(Color.WHITE) && !selectedNodes.contains(node)) {
            g.setPaint(color);
            g.fill(node.getTransformedPolygon());
        }
    }

    g.setPaint(currentPaint);
}

From source file:com.jivesoftware.os.miru.cluster.MiruReplicaSetDirector.java

public void elect(MiruHost host, MiruTenantId tenantId, MiruPartitionId partitionId, long electionId)
        throws Exception {
    ListMultimap<MiruHost, TenantAndPartition> coords = ArrayListMultimap.create();
    coords.put(host, new TenantAndPartition(tenantId, partitionId));
    clusterRegistry.ensurePartitionCoords(coords);
    clusterRegistry.addToReplicaRegistry(coords, electionId);
}