/** * Adds an aggregated {@code UsageStats} object, to be returned by {@link #queryUsageStats}. * Construct these objects with {@link UsageStatsBuilder}, and set the firstTimestamp and * lastTimestamp fields to make time filtering work in {@link #queryUsageStats}. * * @param intervalType An interval type constant, e.g. {@link UsageStatsManager#INTERVAL_WEEKLY}. */ public void addUsageStats(int intervalType, UsageStats stats) { usageStatsByIntervalType.put(intervalType, stats); }
public LineHashSequence(List<String> hashes) { this.hashes = hashes; this.lineByHash = HashMultimap.create(); int lineNo = 1; for (String hash : hashes) { lineByHash.put(hash, lineNo); lineNo++; } }
private void addToComponentSpecificHandlers(Class<? extends Event> type, EventHandlerInfo handlerInfo, Class<? extends Component> c) { SetMultimap<Class<? extends Component>, EventHandlerInfo> componentMap = componentSpecificHandlers.get(type); if (componentMap == null) { componentMap = HashMultimap.create(); componentSpecificHandlers.put(type, componentMap); } componentMap.put(c, handlerInfo); }
@Override public synchronized void noMoreSplits(PlanNodeId sourceId, Lifespan lifespan) { if (pendingNoMoreSplitsForLifespan.put(sourceId, lifespan)) { needsUpdate.set(true); scheduleUpdate(); } }
public void assignRole(String user, PluginRoleConfig pluginRoleConfig) { roleToUsersMappings.put(pluginRoleConfig, new RoleUser(user)); }
@Override protected SetMultimap<String, String> create(Entry<String, String>[] entries) { SetMultimap<String, String> multimap = LinkedHashMultimap.create(); for (Entry<String, String> entry : entries) { multimap.put(entry.getKey(), entry.getValue()); } return multimap; } })
@Override protected SetMultimap<String, String> create(Entry<String, String>[] entries) { SetMultimap<String, String> multimap = HashMultimap.create(); for (Entry<String, String> entry : entries) { multimap.put(entry.getKey(), entry.getValue()); } return multimap; } })
@Override public SetMultimap<String, Integer> create(Object... elements) { SetMultimap<String, Integer> multimap = LinkedHashMultimap.create(); for (Object o : elements) { @SuppressWarnings("unchecked") Entry<String, Integer> entry = (Entry<String, Integer>) o; multimap.put(entry.getKey(), entry.getValue()); } return filter(multimap); }
private static void putForTextRange(SetMultimap<Integer, ScannerReport.Symbol> res, ScannerReport.Symbol symbol, ScannerReport.TextRange declaration) { for (int i = declaration.getStartLine(); i <= declaration.getEndLine(); i++) { res.put(i, symbol); } }
@Override protected void doAdd(InputFile inputFile) { if (inputFile.language() != null) { languages.add(inputFile.language()); } fileMap.put(inputFile.relativePath(), inputFile); filesByNameCache.put(inputFile.filename(), inputFile); filesByExtensionCache.put(FileExtensionPredicate.getExtension(inputFile), inputFile); }
public void testFilteredKeysSetMultimapReplaceValues() { SetMultimap<String, Integer> multimap = LinkedHashMultimap.create(); multimap.put("foo", 1); multimap.put("bar", 2); multimap.put("baz", 3); multimap.put("bar", 4); SetMultimap<String, Integer> filtered = Multimaps.filterKeys(multimap, Predicates.in(ImmutableSet.of("foo", "bar"))); assertEquals(ImmutableSet.of(), filtered.replaceValues("baz", ImmutableSet.<Integer>of())); try { filtered.replaceValues("baz", ImmutableSet.of(5)); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
public InputComponentStore put(String moduleKey, InputFile inputFile) { DefaultInputFile file = (DefaultInputFile) inputFile; addToLanguageCache(moduleKey, file); inputFileByModuleCache.put(moduleKey, file.getModuleRelativePath(), inputFile); globalInputFileCache.put(file.getProjectRelativePath(), inputFile); inputComponents.put(inputFile.key(), inputFile); filesByNameCache.put(inputFile.filename(), inputFile); filesByExtensionCache.put(FileExtensionPredicate.getExtension(inputFile), inputFile); return this; }
@Override protected SetMultimap<String, String> create(Entry<String, String>[] entries) { TestMultimap<String, String> inner = new TestMultimap<>(); SetMultimap<String, String> outer = Synchronized.setMultimap(inner, inner.mutex); for (Entry<String, String> entry : entries) { outer.put(entry.getKey(), entry.getValue()); } return outer; } })
public void testFilteredKeysSetMultimapGetBadValue() { SetMultimap<String, Integer> multimap = LinkedHashMultimap.create(); multimap.put("foo", 1); multimap.put("bar", 2); multimap.put("baz", 3); multimap.put("bar", 4); SetMultimap<String, Integer> filtered = Multimaps.filterKeys(multimap, Predicates.in(ImmutableSet.of("foo", "bar"))); Set<Integer> bazSet = filtered.get("baz"); assertThat(bazSet).isEmpty(); try { bazSet.add(5); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } try { bazSet.addAll(ImmutableSet.of(6, 7)); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@Override protected SetMultimap<String, String> create(Entry<String, String>[] entries) { SetMultimap<String, String> multimap = TreeMultimap.create( Ordering.natural().nullsFirst(), Ordering.natural().nullsFirst()); for (Entry<String, String> entry : entries) { multimap.put(entry.getKey(), entry.getValue()); } return multimap; }
@MapFeature.Require(SUPPORTS_PUT) public void testPutDuplicateValue() { List<Entry<K, V>> entries = copyToList(multimap().entries()); for (Entry<K, V> entry : entries) { resetContainer(); K k = entry.getKey(); V v = entry.getValue(); Set<V> values = multimap().get(k); Set<V> expectedValues = copyToSet(values); assertFalse(multimap().put(k, v)); assertEquals(expectedValues, values); assertGet(k, expectedValues); } }
@MapFeature.Require({SUPPORTS_PUT, ALLOWS_NULL_VALUES}) @CollectionSize.Require(absent = ZERO) public void testPutDuplicateValue_null() { initMultimapWithNullValue(); assertFalse(multimap().put(getKeyForNullValue(), null)); expectContents(createArrayWithNullValue()); } }
@MapFeature.Require(SUPPORTS_PUT) @CollectionSize.Require(absent = ZERO) public void testPutDuplicateValuePreservesSize() { assertFalse(multimap().put(k0(), v0())); assertEquals(getNumElements(), multimap().size()); }