List of usage examples for com.google.common.collect ArrayListMultimap create
public static <K, V> ArrayListMultimap<K, V> create()
From source file:net.shibboleth.idp.profile.context.MultiRelyingPartyContext.java
/** Constructor. */ public MultiRelyingPartyContext() { relyingPartyIdMap = new HashMap<>(); relyingPartyLabelMap = ArrayListMultimap.create(); }
From source file:com.opengamma.strata.collect.io.IniFile.java
private static Map<String, Multimap<String, String>> parse(ImmutableList<String> lines) { Map<String, Multimap<String, String>> ini = new LinkedHashMap<>(); Multimap<String, String> currentSection = null; int lineNum = 0; for (String line : lines) { lineNum++;/*from w w w . j a va 2 s. c om*/ line = line.trim(); if (line.length() == 0 || line.startsWith("#") || line.startsWith(";")) { continue; } if (line.startsWith("[") && line.endsWith("]")) { String sectionName = line.substring(1, line.length() - 1).trim(); if (ini.containsKey(sectionName)) { throw new IllegalArgumentException( "Invalid INI file, duplicate section not allowed, line " + lineNum); } currentSection = ArrayListMultimap.create(); ini.put(sectionName, currentSection); } else if (currentSection == null) { throw new IllegalArgumentException( "Invalid INI file, properties must be within a [section], line " + lineNum); } else { 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 INI file, empty key, line " + lineNum); } currentSection.put(key, value); } } return ini; }
From source file:org.gradle.api.internal.artifacts.resolution.DefaultArtifactResolutionQuery.java
public ArtifactResolutionQueryResult execute() { final List<Dependency> artifactDependencies = createArtifactDependencies(); Configuration configuration = configurationContainer .detachedConfiguration(artifactDependencies.toArray(new Dependency[artifactDependencies.size()])); Multimap<ComponentIdentifier, JvmLibraryArtifact> jvmLibraryArtifacts = ArrayListMultimap.create(); LenientConfiguration lenientConfiguration = configuration.getResolvedConfiguration() .getLenientConfiguration();/*from w w w . j a v a 2 s . com*/ Set<ResolvedArtifact> resolvedArtifacts = lenientConfiguration.getArtifacts(Specs.satisfyAll()); // TODO: handle resolution failures (lenientConfiguration.getUnresolvedModuleDependencies) for (ResolvedArtifact artifact : resolvedArtifacts) { ModuleComponentIdentifier componentId = toComponentIdentifier(artifact.getModuleVersion().getId()); jvmLibraryArtifacts.put(componentId, toJvmLibraryArtifact(artifact)); } Set<JvmLibrary> jvmLibraries = Sets.newHashSet(); for (Map.Entry<ComponentIdentifier, Collection<JvmLibraryArtifact>> entry : jvmLibraryArtifacts.asMap() .entrySet()) { jvmLibraries.add(new DefaultJvmLibrary(entry.getKey(), ImmutableList.copyOf(entry.getValue()))); } return new DefaultArtifactResolutionQueryResult(jvmLibraries); }
From source file:de.ii.xtraplatform.feature.provider.pgis.NestedSqlInsertRow.java
void addRow(String path) { String parentPath = path.substring(0, path.lastIndexOf("/")); NestedSqlInsertRow nestedParent = getNested(parentPath); if (nestedParent == null && parentPath.contains("/")) { parentPath = parentPath.substring(0, parentPath.lastIndexOf("/")); nestedParent = getNested(parentPath); }//from w ww . ja v a2 s.c om if (nestedParent != null) { String subPath = path.substring(parentPath.length()); nestedParent.rows.put(subPath, new NestedSqlInsertRow(subPath, ArrayListMultimap.create())); } }
From source file:org.glowroot.agent.model.TraceEntryComponent.java
public List<Trace.Entry> toProto(long captureTick, Multimap<TraceEntryImpl, TraceEntryImpl> asyncRootTraceEntries) { if (captureTick < startTick) { return ImmutableList.of(); }//from www .j a v a2 s .com boolean completed = this.completed; if (completed && endTick < captureTick) { completed = false; } ListMultimap<TraceEntryImpl, TraceEntryImpl> parentChildMap = ArrayListMultimap.create(); TraceEntryImpl entry = rootEntry.getNextTraceEntry(); // filter out entries that started after the capture tick // checking completed is short circuit optimization for the common case while (entry != null && (completed || Tickers.lessThanOrEqual(entry.getStartTick(), captureTick))) { // checkNotNull is safe because only the root entry has null parent TraceEntryImpl parentTraceEntry = checkNotNull(entry.getParentTraceEntry()); parentChildMap.put(parentTraceEntry, entry); entry = entry.getNextTraceEntry(); } // merge in async trace entry roots for (Entry<TraceEntryImpl, Collection<TraceEntryImpl>> entries : asyncRootTraceEntries.asMap().entrySet()) { TraceEntryImpl parentTraceEntry = entries.getKey(); List<TraceEntryImpl> childTraceEntries = Lists.newArrayList(parentChildMap.get(parentTraceEntry)); for (TraceEntryImpl asyncRootTraceEntry : entries.getValue()) { TraceEntryImpl loopEntry = asyncRootTraceEntry; while (loopEntry != null && (completed || Tickers.lessThanOrEqual(loopEntry.getStartTick(), captureTick))) { TraceEntryImpl loopParentEntry = loopEntry.getParentTraceEntry(); if (loopParentEntry == null) { childTraceEntries.add(loopEntry); } else { parentChildMap.put(loopParentEntry, loopEntry); } loopEntry = loopEntry.getNextTraceEntry(); } } childTraceEntries = TraceEntryImpl.orderingByStartTick.sortedCopy(childTraceEntries); parentChildMap.replaceValues(parentTraceEntry, childTraceEntries); } return getProtobufChildEntries(rootEntry, parentChildMap, startTick, captureTick); }
From source file:eu.interedition.collatex.dekker.matrix.IslandConflictResolver.java
public Multimap<IslandCompetition, Island> analyzeConflictsBetweenPossibleIslands( List<Island> possibleIslands) { Multimap<IslandCompetition, Island> conflictMap = ArrayListMultimap.create(); Set<Island> competingIslands = getCompetingIslands(possibleIslands); for (Island island : competingIslands) { if (selection.doesCandidateLayOnVectorOfCommittedIsland(island)) { conflictMap.put(IslandCompetition.CompetingIslandAndOnIdealIine, island); } else {/*from w ww . ja v a 2s . co m*/ conflictMap.put(IslandCompetition.CompetingIsland, island); } } for (Island island : getNonCompetingIslands(possibleIslands, competingIslands)) { conflictMap.put(IslandCompetition.NonCompetingIsland, island); } return conflictMap; }
From source file:org.apache.drill.exec.store.schedule.OldAssignmentCreator.java
OldAssignmentCreator(List<DrillbitEndpoint> incomingEndpoints, List<T> units) { logger.debug("Assigning {} units to {} endpoints", units.size(), incomingEndpoints.size()); Stopwatch watch = new Stopwatch(); Preconditions.checkArgument(incomingEndpoints.size() <= units.size(), String.format("Incoming endpoints %d " + "is greater than number of row groups %d", incomingEndpoints.size(), units.size())); this.mappings = ArrayListMultimap.create(); this.endpoints = Lists.newLinkedList(incomingEndpoints); ArrayList<T> rowGroupList = new ArrayList<>(units); for (double cutoff : ASSIGNMENT_CUTOFFS) { scanAndAssign(rowGroupList, cutoff, false, false); }/* w w w . j av a 2 s . c om*/ scanAndAssign(rowGroupList, 0.0, true, false); scanAndAssign(rowGroupList, 0.0, true, true); logger.debug("Took {} ms to apply assignments", watch.elapsed(TimeUnit.MILLISECONDS)); Preconditions.checkState(rowGroupList.isEmpty(), "All readEntries should be assigned by now, but some are still unassigned"); Preconditions.checkState(!units.isEmpty()); }
From source file:eu.esdihumboldt.hale.common.align.model.transformation.tree.impl.CellNodeImpl.java
/** * Create a cell node w/o associated sources. Sources can be added later on * through {@link #addSource(Set, SourceNode)} * //from ww w . ja v a 2s .c om * @param cell the associated cell */ public CellNodeImpl(Cell cell) { this.cell = cell; sources = ArrayListMultimap.create(); }
From source file:org.opendaylight.controller.md.sal.dom.store.impl.ResolveDataChangeEventsTask.java
/** * Resolves and submits notification tasks to the specified manager. */// ww w. ja va 2s .c om public synchronized void resolve( final NotificationManager<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent> manager) { try (final RegistrationTreeSnapshot<DataChangeListenerRegistration<?>> w = listenerRoot.takeSnapshot()) { // Defensive: reset internal state collectedEvents = ArrayListMultimap.create(); // Run through the tree final ResolveDataChangeState s = ResolveDataChangeState.initial(candidate.getRootPath(), w.getRootNode()); resolveAnyChangeEvent(s, candidate.getRootNode()); /* * Convert to tasks, but be mindful of multiple values -- those indicate multiple * wildcard matches, which need to be merged. */ for (Entry<DataChangeListenerRegistration<?>, Collection<DOMImmutableDataChangeEvent>> e : collectedEvents .asMap().entrySet()) { final Collection<DOMImmutableDataChangeEvent> col = e.getValue(); final DOMImmutableDataChangeEvent event; if (col.size() != 1) { final Builder b = DOMImmutableDataChangeEvent.builder(DataChangeScope.BASE); for (DOMImmutableDataChangeEvent i : col) { b.merge(i); } event = b.build(); LOG.trace("Merged events {} into event {}", col, event); } else { event = col.iterator().next(); } manager.submitNotification(e.getKey(), event); } } }
From source file:org.onosproject.net.intent.impl.InstallCoordinator.java
/** * Applies Intent data to be uninstalled and to be installed. * * @param toUninstall Intent data to be uninstalled * @param toInstall Intent data to be installed *///from ww w. j av a2 s . co m public void installIntents(Optional<IntentData> toUninstall, Optional<IntentData> toInstall) { // If no any Intents to be uninstalled or installed, ignore it. if (!toUninstall.isPresent() && !toInstall.isPresent()) { return; } // Classify installable Intents to different installers. ArrayListMultimap<IntentInstaller, Intent> uninstallInstallers; ArrayListMultimap<IntentInstaller, Intent> installInstallers; Set<IntentInstaller> allInstallers = Sets.newHashSet(); if (toUninstall.isPresent()) { uninstallInstallers = getInstallers(toUninstall.get()); allInstallers.addAll(uninstallInstallers.keySet()); } else { uninstallInstallers = ArrayListMultimap.create(); } if (toInstall.isPresent()) { installInstallers = getInstallers(toInstall.get()); allInstallers.addAll(installInstallers.keySet()); } else { installInstallers = ArrayListMultimap.create(); } // Generates an installation context for the high level Intent. IntentInstallationContext installationContext = new IntentInstallationContext(toUninstall.orElse(null), toInstall.orElse(null)); //Generates different operation context for different installable Intents. Map<IntentInstaller, IntentOperationContext> contexts = Maps.newHashMap(); allInstallers.forEach(installer -> { List<Intent> intentsToUninstall = uninstallInstallers.get(installer); List<Intent> intentsToInstall = installInstallers.get(installer); // Connect context to high level installation context IntentOperationContext context = new IntentOperationContext(intentsToUninstall, intentsToInstall, installationContext); installationContext.addPendingContext(context); contexts.put(installer, context); }); // Apply contexts to installers contexts.forEach((installer, context) -> { installer.apply(context); }); }