List of usage examples for com.google.common.collect LinkedListMultimap create
public static <K, V> LinkedListMultimap<K, V> create()
From source file:com.tinspx.util.net.Headers.java
public Headers() { this.headers = LinkedListMultimap.create(); }
From source file:com.android.tools.idea.templates.GradleFileMerger.java
private static void mergeDependencies(@NotNull PsiElement fromRoot, @NotNull PsiElement toRoot, @NotNull Project project) {/*from w w w.j a va2 s . c o m*/ Multimap<String, GradleCoordinate> dependencies = LinkedListMultimap.create(); List<String> unparseableDependencies = new ArrayList<String>(); // Load existing dependencies into the map for the existing build.gradle pullDependenciesIntoMap(toRoot, dependencies, null); // Load dependencies into the map for the new build.gradle pullDependenciesIntoMap(fromRoot, dependencies, unparseableDependencies); GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project); RepositoryUrlManager urlManager = RepositoryUrlManager.get(); for (String key : dependencies.keySet()) { GradleCoordinate highest = Collections.max(dependencies.get(key), COMPARE_PLUS_LOWER); // For test consistency, don't depend on installed SDK state while testing if (!ApplicationManager.getApplication().isUnitTestMode() || Boolean.getBoolean("force.gradlemerger.repository.check")) { // If this coordinate points to an artifact in one of our repositories, check to see if there is a static version // that we can add instead of a plus revision. if (RepositoryUrlManager.supports(highest.getArtifactId())) { String libraryCoordinate = urlManager.getLibraryCoordinate(highest.getArtifactId(), null, false /* No previews */); GradleCoordinate available = GradleCoordinate.parseCoordinateString(libraryCoordinate); if (available != null) { File archiveFile = urlManager.getArchiveForCoordinate(available); if (archiveFile != null && archiveFile.exists() && COMPARE_PLUS_LOWER.compare(available, highest) >= 0) { highest = available; } } } } PsiElement dependencyElement = factory .createStatementFromText(String.format(COMPILE_FORMAT, highest.toString())); toRoot.addBefore(dependencyElement, toRoot.getLastChild()); } for (String unparseableDependency : unparseableDependencies) { PsiElement dependencyElement = factory.createStatementFromText(unparseableDependency); toRoot.addBefore(dependencyElement, toRoot.getLastChild()); } }
From source file:org.envirocar.server.mongo.MongoDB.java
protected <T> ListMultimap<String, Key<T>> getKindMap(Class<T> clazz, List<Key<T>> keys) { ListMultimap<String, Key<T>> kindMap = LinkedListMultimap.create(); String clazzKind = (clazz == null) ? null : getMapper().getCollectionName(clazz); for (Key<T> key : keys) { getMapper().updateKind(key);/* ww w. j a v a 2 s .c o m*/ String kind = key.getKind(); if (clazzKind != null && !kind.equals(clazzKind)) { throw new IllegalArgumentException( String.format("Types are not equal (%s!=%s) for key and method parameter clazz", clazz, key.getKindClass())); } kindMap.put(kind, key); } return kindMap; }
From source file:net.tridentsdk.server.bench.Benchmarks.java
public static LinkedListMultimap<String, Double> parse(String lines) { LinkedListMultimap<String, Double> list = LinkedListMultimap.create(); for (String s : lines.split("\n")) { String[] split = s.split(" "); list.put(split[0], Double.parseDouble(split[1])); }/* w w w. j av a 2 s .c o m*/ return list; }
From source file:org.sonar.java.checks.MembersDifferOnlyByCapitalizationCheck.java
private static Multimap<String, Symbol> sortByName(List<Symbol> members) { Multimap<String, Symbol> membersByName = LinkedListMultimap.create(); for (Symbol member : members) { membersByName.put(member.name(), member); }/*from w w w . j a v a2 s .c om*/ return membersByName; }
From source file:de.iteratec.iteraplan.businesslogic.service.ecore.MappedEPackage.java
public MappedEPackage(EPackage wrapped) { this.eSFtoAT = HashBiMap.create(); this.atToEEnum = HashBiMap.create(); this.bbToEClass = HashBiMap.create(); this.atToAVStrings = LinkedListMultimap.create(); this.wrapped = wrapped; }
From source file:org.bitstrings.maven.plugins.portallocator.PortAllocatorMojo.java
@Override public void execute() throws MojoExecutionException, MojoFailureException { try {/* w w w . j a v a 2 s .c o m*/ if (portAllocators != null) { for (PortAllocator portAllocator : portAllocators) { initPortAllocator(portAllocator); final PortAllocatorService existingPas = PORT_ALLOCATOR_SERVICE_MAP.get(portAllocator.getId()); if (portAllocator.isPermitOverride() || (existingPas == null) || (portAllocator.getId().equals(PORT_ALLOCATOR_DEFAULT_ID) && (existingPas == PORT_ALLOCATOR_SERVICE_DEFAULT))) { PORT_ALLOCATOR_SERVICE_MAP.put(portAllocator.getId(), createPortAllocatorService(portAllocator)); if (!quiet && getLog().isInfoEnabled()) { getLog().info("Registering port allocator [" + portAllocator.getId() + "]"); } } } } if (ports != null) { if ((ports.getPortAllocatorRef() != null) && (ports.getPortAllocator() != null)) { throw new MojoExecutionException( "Either use a port allocator reference or define an inner allocator but you can use both."); } PortAllocatorService pas = ports.getPortAllocator() == null ? PORT_ALLOCATOR_SERVICE_MAP .get(firstNonNull(ports.getPortAllocatorRef(), PORT_ALLOCATOR_DEFAULT_ID)) : createPortAllocatorService(initPortAllocator(ports.getPortAllocator())); if (pas == null) { throw new MojoExecutionException( "Cannot find port allocator [" + ports.getPortAllocatorRef() + "]"); } // assign final LinkedListMultimap<String, Port> portGroupMap = LinkedListMultimap.create(); for (Port port : ports) { final String offsetFrom = port.getOffsetFrom(); final String portGroupName = findGroupRoot(port, portGroupMap); portGroupMap.put(portGroupName, port); if ((offsetFrom != null) && !executionPortMap.containsKey(getPortName(portGroupName))) { throw new MojoExecutionException( "Port [" + port.getName() + "] using offset from undefined [" + offsetFrom + "]."); } Iterator<Port> portIterator = Iterators.singletonIterator(port); while (portIterator.hasNext()) { final Port portToAllocate = portIterator.next(); final Integer previousPort = executionPortMap.remove(getPortName(portToAllocate.getName())); executionPortMap.remove(getOffsetName(portToAllocate.getName())); if (!allocatePort(pas, portToAllocate)) { if (portToAllocate.getOffsetFrom() != null) { portIterator = portGroupMap.get(portGroupName).listIterator(); } } ALLOCATION_LOCK.lock(); ALLOCATED_PORTS.remove(previousPort); ALLOCATION_LOCK.unlock(); } } // log ports for (Port port : ports) { if (!quiet && getLog().isInfoEnabled()) { String name = getPortName(port.getName()); Integer value = executionPortMap.get(name); if (value != null) { getLog().info("Assigning port [" + value + "] to property [" + name + "]"); } name = getOffsetName(port.getName()); value = executionPortMap.get(name); if (value != null) { getLog().info("Assigning offset [" + value + "] " + "using preferred port [" + port.getPreferredPort() + "] " + "to property [" + name + "]"); } } } } if (writePropertiesFile != null) { final File parent = writePropertiesFile.getParentFile(); if ((parent != null) && !parent.exists()) { parent.mkdirs(); } try (final Writer out = new BufferedWriter(new FileWriter(writePropertiesFile))) { if (!quiet && getLog().isInfoEnabled()) { getLog().info("Writing ports file [" + writePropertiesFile + "]"); } final Properties outProps = new Properties(); outProps.putAll(Maps.transformValues(executionPortMap, new Function<Integer, String>() { @Override public String apply(Integer input) { return input.toString(); } })); outProps.store(out, null); } catch (Exception e) { throw new MojoExecutionException("Problem writing ports file [" + writePropertiesFile + "]", e); } } } catch (MojoExecutionException e) { throw e; } catch (Exception e) { throw new MojoExecutionException(e.getLocalizedMessage(), e); } }
From source file:org.eclipse.elk.layered.intermediate.SplineSelfLoopPreProcessor.java
/** * Creates a set of all connected components. If there are ports with no edge, they will form a * component of size 1. If there are edges connecting ports not in the list of ports, this will * result in unpredictable behavior.// ww w .ja v a 2s . c om * * @param loopEdges The edges connecting the ports. They may not connect any ports not in the list * of ports! * @param node The node we are currently working on. * @return A set of sets. Every single set represents a connected component. */ private static List<ConnectedSelfLoopComponent> findAllConnectedComponents(final Set<LEdge> loopEdges, final LNode node) { final List<ConnectedSelfLoopComponent> components = Lists.newArrayList(); final Multimap<LPort, LEdge> portToEdge = LinkedListMultimap.create(); for (final LEdge edge : loopEdges) { portToEdge.put(edge.getSource(), edge); portToEdge.put(edge.getTarget(), edge); } while (!portToEdge.isEmpty()) { components.add(findAConnectedComponent(portToEdge, node, node.getProperty(LayoutOptions.PORT_CONSTRAINTS).isOrderFixed())); } return components; }
From source file:org.eclipse.elk.alg.layered.intermediate.SplineSelfLoopPreProcessor.java
/** * Creates a set of all connected components. If there are ports with no edge, they will form a * component of size 1. If there are edges connecting ports not in the list of ports, this will * result in unpredictable behavior.//from www .ja v a2 s . c o m * * @param loopEdges The edges connecting the ports. They may not connect any ports not in the list * of ports! * @param node The node we are currently working on. * @return A set of sets. Every single set represents a connected component. */ private static List<ConnectedSelfLoopComponent> findAllConnectedComponents(final Set<LEdge> loopEdges, final LNode node) { final List<ConnectedSelfLoopComponent> components = Lists.newArrayList(); final Multimap<LPort, LEdge> portToEdge = LinkedListMultimap.create(); for (final LEdge edge : loopEdges) { portToEdge.put(edge.getSource(), edge); portToEdge.put(edge.getTarget(), edge); } while (!portToEdge.isEmpty()) { components.add(findAConnectedComponent(portToEdge, node, node.getProperty(LayeredOptions.PORT_CONSTRAINTS).isOrderFixed())); } return components; }
From source file:net.tridentsdk.server.bench.Benchmarks.java
public static LinkedListMultimap<String, Double> parse(Collection<RunResult> results) { LinkedListMultimap<String, Double> data = LinkedListMultimap.create(); for (RunResult result : results) { for (BenchmarkResult result0 : result.getBenchmarkResults()) { System.out.println(/*from www.j av a 2 s.c o m*/ result0.getPrimaryResult().getLabel() + " " + result0.getPrimaryResult().getScore()); data.put(result0.getPrimaryResult().getLabel(), result0.getPrimaryResult().getScore()); } } return data; }