Refine search
Multimap<String, IndexEntry> uniq = LinkedListMultimap.create(); for (IndexEntry e : additions) { uniq.put(e.field, e); for (Map.Entry<String, Collection<IndexEntry>> add : uniq.asMap().entrySet()) { KeyInformation keyInformation = informations.get(add.getKey()); Object value = null; case SET: case LIST: value = add.getValue().stream().map(v -> convertToEsType(v.value)).collect(Collectors.toList()).toArray(); break;
public void testCreateFromMultimap() { Multimap<String, Integer> multimap = LinkedListMultimap.create(); multimap.put("foo", 1); multimap.put("bar", 3); multimap.put("foo", 2); LinkedListMultimap<String, Integer> copy = LinkedListMultimap.create(multimap); assertEquals(multimap, copy); assertThat(copy.entries()).containsExactlyElementsIn(multimap.entries()).inOrder(); }
/** * @serialData the number of distinct keys, and then for each distinct key: the first key, the * number of values for that key, and the key's values, followed by successive keys and values * from the entries() ordering */ @GwtIncompatible // java.io.ObjectOutputStream private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); stream.writeInt(size()); for (Entry<K, V> entry : entries()) { stream.writeObject(entry.getKey()); stream.writeObject(entry.getValue()); } }
public static LinkedListMultimap<Object, Object> instantiate(SerializationStreamReader in) throws SerializationException { LinkedListMultimap<Object, Object> multimap = LinkedListMultimap.create(); int size = in.readInt(); for (int i = 0; i < size; i++) { Object key = in.readObject(); Object value = in.readObject(); multimap.put(key, value); } return multimap; }
/** * @param i individual * @param ontology ontology to search * @return property values */ public static Multimap<OWLObjectPropertyExpression, OWLIndividual> getNegativeObjectPropertyValues( OWLIndividual i, OWLOntology ontology) { Multimap<OWLObjectPropertyExpression, OWLIndividual> map = LinkedListMultimap.create(); ontology.negativeObjectPropertyAssertionAxioms(i) .forEach(ax -> map.put(ax.getProperty(), ax.getObject())); return map; }
/** * @param i individual * @param ontology ontology to search * @return property values */ public static Multimap<OWLDataPropertyExpression, OWLLiteral> getDataPropertyValues( OWLIndividual i, OWLOntology ontology) { Multimap<OWLDataPropertyExpression, OWLLiteral> map = LinkedListMultimap.create(); ontology.dataPropertyAssertionAxioms(i) .forEach(ax -> map.put(ax.getProperty(), ax.getObject())); return map; }
/** * @param i individual * @param ontology ontology to search * @return property values */ public static Multimap<OWLDataPropertyExpression, OWLLiteral> getNegativeDataPropertyValues( OWLIndividual i, OWLOntology ontology) { Multimap<OWLDataPropertyExpression, OWLLiteral> map = LinkedListMultimap.create(); ontology.negativeDataPropertyAssertionAxioms(i) .forEach(ax -> map.put(ax.getProperty(), ax.getObject())); return map; }
/** * @param i individual * @param ontology ontology to search * @return property values */ public static Multimap<OWLObjectPropertyExpression, OWLIndividual> getObjectPropertyValues( OWLIndividual i, OWLOntology ontology) { Multimap<OWLObjectPropertyExpression, OWLIndividual> map = LinkedListMultimap.create(); ontology.objectPropertyAssertionAxioms(i) .forEach(ax -> map.put(ax.getProperty(), ax.getObject())); return map; }
ListMultimap<StoreInfo, LayerInfo> affectedLayers = LinkedListMultimap.create(); if (affectedLayers.containsKey(store)) { affectedLayers.put(store, layerInfo); } else { @Nullable final String dataStoreHead = findDataStoreHeadRefName(store, context); if (newRefName.equals(dataStoreHead)) { affectedLayers.put(store, layerInfo);
public void testBuilderPutAllMultimap() { Multimap<String, Integer> toPut = LinkedListMultimap.create(); toPut.put("foo", 1); toPut.put("bar", 4); toPut.put("foo", 2); toPut.put("foo", 3); Multimap<String, Integer> moreToPut = LinkedListMultimap.create(); moreToPut.put("foo", 6); moreToPut.put("bar", 5); moreToPut.put("foo", 7); ImmutableListMultimap.Builder<String, Integer> builder = ImmutableListMultimap.builder(); builder.putAll(toPut); builder.putAll(moreToPut); Multimap<String, Integer> multimap = builder.build(); assertEquals(Arrays.asList(1, 2, 3, 6, 7), multimap.get("foo")); assertEquals(Arrays.asList(4, 5), multimap.get("bar")); assertEquals(7, multimap.size()); }
public InvoiceGeneratorResult generateItems(final ImmutableAccountData account, final UUID invoiceId, final BillingEventSet eventSet, @Nullable final Iterable<Invoice> existingInvoices, final LocalDate targetDate, final Currency targetCurrency, final Map<UUID, SubscriptionFutureNotificationDates> perSubscriptionFutureNotificationDate, final InternalCallContext internalCallContext) throws InvoiceApiException { final Multimap<UUID, LocalDate> createdItemsPerDayPerSubscription = LinkedListMultimap.<UUID, LocalDate>create();
public void register(BeanFactory beanFactory, String key, SpringValue springValue) { if (!registry.containsKey(beanFactory)) { synchronized (LOCK) { if (!registry.containsKey(beanFactory)) { registry.put(beanFactory, LinkedListMultimap.<String, SpringValue>create()); } } } registry.get(beanFactory).put(key, springValue); // lazy initialize if (initialized.compareAndSet(false, true)) { initialize(); } }
@GwtIncompatible(value = "untested") public void testTransformValuesIsView() { Multimap<String, String> multimap = LinkedListMultimap.create(); multimap.put("a", "a"); Multimap<String, Integer> transformed = Multimaps.transformValues( multimap, new Function<String, Integer>() { @Override public Integer apply(String str) { return str.length(); } }); Entry<String, String> entry = multimap.entries().iterator().next(); entry.setValue("bbb"); assertThat(transformed.entries()).containsExactly(immutableEntry("a", 3)); }
/** * Returns a multimap with all empty strings (as keys or values) replaced by a non-empty human * understandable indicator for an empty string. * * <p>Returns the given multimap if it contains no empty strings. */ private static Multimap<?, ?> annotateEmptyStringsMultimap(Multimap<?, ?> multimap) { if (multimap.containsKey("") || multimap.containsValue("")) { ListMultimap<Object, Object> annotatedMultimap = LinkedListMultimap.create(); for (Entry<?, ?> entry : multimap.entries()) { Object key = "".equals(entry.getKey()) ? HUMAN_UNDERSTANDABLE_EMPTY_STRING : entry.getKey(); Object value = "".equals(entry.getValue()) ? HUMAN_UNDERSTANDABLE_EMPTY_STRING : entry.getValue(); annotatedMultimap.put(key, value); } return annotatedMultimap; } else { return multimap; } }
public void testSynchronizedLinkedListMultimapRandomAccess() { ListMultimap<String, Integer> delegate = LinkedListMultimap.create(); delegate.put("foo", 1); delegate.put("foo", 3); ListMultimap<String, Integer> multimap = Multimaps.synchronizedListMultimap(delegate); assertFalse(multimap.get("foo") instanceof RandomAccess); assertFalse(multimap.get("bar") instanceof RandomAccess); } }