List of usage examples for com.google.common.collect ArrayListMultimap create
public static <K, V> ArrayListMultimap<K, V> create()
From source file:org.opendaylight.mdsal.dom.broker.ProducerLayout.java
private static BiMap<DOMDataTreeIdentifier, DOMDataTreeShardProducer> mapIdsToProducer( final Map<DOMDataTreeIdentifier, DOMDataTreeShard> shardMap) { final Multimap<DOMDataTreeShard, DOMDataTreeIdentifier> shardToId = ArrayListMultimap.create(); // map which identifier belongs to which shard for (final Entry<DOMDataTreeIdentifier, DOMDataTreeShard> entry : shardMap.entrySet()) { shardToId.put(entry.getValue(), entry.getKey()); }//from www .java 2 s.c om final Builder<DOMDataTreeIdentifier, DOMDataTreeShardProducer> idToProducerBuilder = ImmutableBiMap .builder(); for (final Entry<DOMDataTreeShard, Collection<DOMDataTreeIdentifier>> entry : shardToId.asMap() .entrySet()) { if (entry.getKey() instanceof WriteableDOMDataTreeShard) { //create a single producer for all prefixes in a single shard final DOMDataTreeShardProducer producer = ((WriteableDOMDataTreeShard) entry.getKey()) .createProducer(entry.getValue()); // id mapped to producers for (final DOMDataTreeIdentifier id : entry.getValue()) { idToProducerBuilder.put(id, producer); } } else { LOG.error("Unable to create a producer for shard that's not a WriteableDOMDataTreeShard"); } } return idToProducerBuilder.build(); }
From source file:com.zimbra.soap.type.KeyValuePair.java
public static Multimap<String, String> toMultimap(List<KeyValuePair> keyValuePairs) { Multimap<String, String> map = ArrayListMultimap.create(); if (keyValuePairs != null) { for (KeyValuePair a : keyValuePairs) { map.put(a.getKey(), a.getValue()); }//from w w w .java2 s. c o m } return map; }
From source file:org.eclipse.viatra.addon.viewers.runtime.specifications.ContainmentQuerySpecificationDescriptor.java
private static Multimap<PParameter, PParameter> getTraceSource(IQuerySpecification<?> specification, PAnnotation annotation) {//from w w w . j a v a 2 s . c om Multimap<PParameter, PParameter> traces = ArrayListMultimap.create(); ParameterReference parameterSource = annotation.getFirstValue(SOURCE, ParameterReference.class) .orElseThrow(() -> new QueryProcessingException("Invalid container value", specification)); ParameterReference parameterTarget = annotation.getFirstValue(TARGET, ParameterReference.class) .orElseThrow(() -> new QueryProcessingException("Invalid item value", specification)); SpecificationDescriptorUtilities.insertToTraces(specification, traces, parameterSource.getName()); SpecificationDescriptorUtilities.insertToTraces(specification, traces, parameterTarget.getName()); return traces; }
From source file:com.opengamma.strata.collect.io.PropertiesFile.java
private static PropertySet parse(ImmutableList<String> lines) { Multimap<String, String> parsed = ArrayListMultimap.create(); int lineNum = 0; for (String line : lines) { lineNum++;/*w ww . ja va 2 s.c o m*/ line = line.trim(); if (line.length() == 0 || line.startsWith("#") || line.startsWith(";")) { continue; } int equalsPosition = line.indexOf('='); String key = (equalsPosition < 0 ? line.trim() : line.substring(0, equalsPosition).trim()); String value = (equalsPosition < 0 ? "" : line.substring(equalsPosition + 1).trim()); if (key.length() == 0) { throw new IllegalArgumentException("Invalid properties file, empty key, line " + lineNum); } parsed.put(key, value); } return PropertySet.of(parsed); }
From source file:google.registry.mapreduce.inputs.ConcatenatingInput.java
@Override public List<InputReader<T>> createReaders() throws IOException { ListMultimap<Integer, InputReader<T>> shards = ArrayListMultimap.create(); int i = 0;/*from www. j a va 2s . c om*/ for (Input<? extends T> input : inputs) { for (InputReader<? extends T> reader : input.createReaders()) { // Covariant cast is safe because an InputReader<I> only outputs I and never consumes it. @SuppressWarnings("unchecked") InputReader<T> typedReader = (InputReader<T>) reader; shards.put(i % numShards, typedReader); i++; } } ImmutableList.Builder<InputReader<T>> concatenatingReaders = new ImmutableList.Builder<>(); for (Collection<InputReader<T>> shard : shards.asMap().values()) { concatenatingReaders.add(new ConcatenatingInputReader<>(ImmutableList.copyOf(shard))); } return concatenatingReaders.build(); }
From source file:com.zimbra.cs.lmtpserver.LmtpEnvelope.java
public LmtpEnvelope() { mRecipients = new LinkedList<LmtpAddress>(); mLocalRecipients = new LinkedList<LmtpAddress>(); mRemoteRecipients = new LinkedList<LmtpAddress>(); mRemoteServerToRecipientsMap = ArrayListMultimap.create(); }
From source file:com.google.enterprise.connector.ldap.LdapSchemaFinder.java
public SchemaResult find(int maxResults) { Multimap<String, String> tempSchema = ArrayListMultimap.create(); Set<SchemaResultError> errors = Sets.newHashSet(); int resultCount = 0; for (Entry<String, Multimap<String, String>> entry : supplier.get().entrySet()) { String key = entry.getKey(); Multimap<String, String> person = entry.getValue(); tempSchema.putAll(person);//from www. j ava2 s.c o m resultCount++; if (resultCount >= maxResults) { break; } } ImmutableMultimap<String, String> schema = ImmutableMultimap.copyOf(tempSchema); SchemaResult schemaResult = new SchemaResult(schema, resultCount, errors); return schemaResult; }
From source file:uk.ac.cam.cl.dtg.picky.client.binding.FileContextLabelBinding.java
@Override protected List<Label> doCompute() throws Exception { ListMultimap<String, String> fileAttributeTypes = ArrayListMultimap.create(); ListMultimap<String, Object> fileAttributeValues = ArrayListMultimap.create(); if (dataset != null) { fileAttributeTypes.put("path", String.class.getSimpleName()); dataset.getFiles().stream().flatMap(fileEntry -> fileEntry.getAttributes().entrySet().stream()) .forEach(e -> {/*from w ww. j a va 2 s. c om*/ fileAttributeTypes.put(e.getKey(), e.getValue().getClass().getSimpleName()); fileAttributeValues.put(e.getKey(), e.getValue()); }); } List<Label> labels = fileAttributeTypes.keySet().stream().sorted().map(attribute -> { Label label = new Label(attribute + " : " + new HashSet<String>(fileAttributeTypes.get(attribute))); label.getProperties().put(ATTRIBUTE, attribute); return label; }).collect(Collectors.toList()); // As of now, toolstips need to be created in FX application thread... Platform.runLater(new Runnable() { @Override public void run() { labels.stream().forEach(label -> { Tooltip toolTip = new Tooltip(Stream .concat(fileAttributeValues.get(label.getProperties().get(ATTRIBUTE).toString()) .stream().distinct().limit(10).sorted().map(Object::toString), Stream.of("...")) .collect(Collectors.toList()).toString()); toolTip.setWrapText(true); label.setTooltip(toolTip); }); } }); return labels; }
From source file:io.sponges.dubtrack4j.event.framework.EventBus.java
public EventBus() { this.consumerMap = ArrayListMultimap.create(); this.lock = new ReentrantReadWriteLock(); }
From source file:com.mgmtp.jfunk.core.mail.MailMessage.java
private static ListMultimap<String, String> createHeaders(final Message message) throws MessagingException { ListMultimap<String, String> headers = ArrayListMultimap.create(); for (@SuppressWarnings("unchecked") Enumeration<Header> headersEnum = message.getAllHeaders(); headersEnum.hasMoreElements();) { Header header = headersEnum.nextElement(); headers.put(header.getName(), header.getValue()); }/*w w w . j av a 2s .c o m*/ return headers; }