List of usage examples for com.google.common.collect Multimap values
Collection<V> values();
From source file:uk.ac.ebi.intact.dataexchange.psimi.solr.IntactSolrSearcher.java
public Collection<InteractorIdCount> searchInteractors(SolrQuery query, IntactFacetField intactFacetField) throws IntactSolrException { Multimap<String, InteractorIdCount> interactors = searchInteractors(query, new IntactFacetField[] { intactFacetField }); return interactors.values(); }
From source file:fr.jcgay.maven.plugin.buildplan.ListPluginMojo.java
public void execute() throws MojoExecutionException, MojoFailureException { Multimap<String, MojoExecution> plan = Groups.ByPlugin.of(calculateExecutionPlan().getMojoExecutions(), plugin);//from ww w.jav a 2 s . co m if (plan.isEmpty()) { getLog().warn("No plugin found with artifactId: " + plugin); } else { TableDescriptor descriptor = ListPluginTableDescriptor.of(plan.values()); for (Map.Entry<String, Collection<MojoExecution>> executions : plan.asMap().entrySet()) { getLog().info(pluginTitleLine(descriptor, executions.getKey())); for (MojoExecution execution : executions.getValue()) { getLog().info(line(descriptor.rowFormat(), execution)); } } } }
From source file:org.opentestsystem.shared.security.domain.SbacUser.java
private Map<String, Collection<GrantedAuthority>> calculateAuthoritiesByTenantId( final Multimap<String, SbacRole> inUserRoles) { Multimap<String, GrantedAuthority> ret = ArrayListMultimap.create(); if (inUserRoles != null) { for (SbacRole role : inUserRoles.values()) { if (role.isApplicableToComponent() && role.getEffectiveTenant() != null && role.getPermissions() != null && role.getPermissions().size() > 0) { ret.putAll(role.getEffectiveTenant().getId(), role.getPermissions()); }/*from w w w . j av a 2 s .c o m*/ } } return ret.asMap(); }
From source file:org.apache.crunch.impl.mr.plan.DotfileUtills.java
/** * Build the plan dotfile despite of the the dotfile-debug mode. * //w w w . j a va 2 s .c o m * @throws IOException */ void buildPlanDotfile(MRExecutor exec, Multimap<Target, JobPrototype> assignments, MRPipeline pipeline, int lastJobID) { try { DotfileWriter dotfileWriter = new DotfileWriter(); for (JobPrototype proto : Sets.newHashSet(assignments.values())) { dotfileWriter.addJobPrototype(proto); } planDotFile = dotfileWriter.buildDotfile(); } catch (Exception ex) { LOG.error("Problem creating debug dotfile:", ex); } }
From source file:com.eucalyptus.util.dns.DnsResolvers.java
@SuppressWarnings("unchecked") private static void addRRset(Name name, final Message response, Record[] records, final int section) { final Multimap<RequestType, Record> rrsets = LinkedHashMultimap.create(); for (Record r : records) { RequestType type = RequestType.typeOf(r.getType()); rrsets.get(type).addAll(Collections2.filter(Arrays.asList(records), type)); }// www .ja va 2 s . c o m Predicate<Record> checkNewRecord = new Predicate<Record>() { @Override public boolean apply(Record input) { for (int s = 1; s <= section; s++) { if (response.findRecord(input, s)) { return false; } } return true; } }; if (rrsets.containsKey(RequestType.CNAME)) { for (Record cnames : Iterables.filter(rrsets.removeAll(RequestType.CNAME), checkNewRecord)) { response.addRecord(cnames, section); } } for (Record sectionRecord : Iterables.filter(rrsets.values(), checkNewRecord)) { response.addRecord(sectionRecord, section); } }
From source file:com.ansorgit.plugins.bash.lang.psi.util.BashAbstractProcessor.java
/** * Returns the best results. It takes all the elements which have been rated the best * and returns the first / last, depending on the parameter. * * @param results The results to check * @param firstResult If the first element of the best element list should be returned. * @param referenceElement/*from w w w . j a va2s.c o m*/ * @return The result */ private PsiElement findBestResult(Multimap<Integer, PsiElement> results, boolean firstResult, PsiElement referenceElement) { if (!hasResults()) { return null; } if (firstResult) { return Iterators.get(results.values().iterator(), 0); } //if the first should not be used return the best element int referenceLevel = preferNeigbourhood && (referenceElement != null) ? BashPsiUtils.blockNestingLevel(referenceElement) : 0; // find the best suitable result rating // The best one is as close as possible to the given referenceElement int bestRating = Integer.MAX_VALUE; int bestDelta = Integer.MAX_VALUE; for (int rating : results.keySet()) { final int delta = Math.abs(referenceLevel - rating); if (delta < bestDelta) { bestDelta = delta; bestRating = rating; } } // now get the best result // if there are equal definitions on the same level we prefer the first if the neighbourhood is not preferred if (preferNeigbourhood) { return Iterators.getLast(results.get(bestRating).iterator()); } else { //return the element which has the lowest textOffset long smallestOffset = Integer.MAX_VALUE; PsiElement bestElement = null; for (PsiElement e : results.get(bestRating)) { //if the element is injected compute the text offset in the real file int textOffset = e.getTextOffset(); if (BashPsiUtils.isInjectedElement(e)) { //fixme optimize this PsiLanguageInjectionHost injectionHost = InjectedLanguageManager.getInstance(e.getProject()) .getInjectionHost(e); if (injectionHost != null) { textOffset = textOffset + injectionHost.getTextOffset(); } } if (textOffset < smallestOffset) { smallestOffset = textOffset; bestElement = e; } } return bestElement; } }
From source file:at.ac.tuwien.infosys.jcloudscale.vm.openstack.OpenStackWrapper.java
/** * Finds if the host, specified by OpenStack host id has the specified address associated with it. * @param hostId The OpenStack id of the host. * @param hostAddress The address that has to be found. * @return <b>true</b> of the address is found. Otherwise -- false. *///from w ww .j a v a 2 s .c o m private boolean hostHasAddressAssociated(String hostId, String hostAddress) { try { Server theServer = openstack.get(hostId); if (theServer == null) { log.severe("Unable to check IP address for host " + hostId + " - host not found"); return false; } Multimap<String, Address> addresses = theServer.getAddresses(); for (Address address : addresses.values()) if (hostAddress.equals(address.getAddr())) return true; } catch (Exception e) { log.info("Trying to get address for openstack instance " + hostId + " failed. Ignoring."); } return false; }
From source file:org.opendaylight.yangtools.yang.model.repo.util.AbstractSchemaRepository.java
@Override public SchemaListenerRegistration registerSchemaSourceListener(final SchemaSourceListener listener) { final SchemaListenerRegistration ret = new AbstractSchemaListenerRegistration(listener) { @Override/*from w w w . j a va 2s.c o m*/ protected void removeRegistration() { listeners.remove(this); } }; synchronized (this) { final Collection<PotentialSchemaSource<?>> col = new ArrayList<>(); for (Multimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>> m : sources .values()) { for (AbstractSchemaSourceRegistration<?> r : m.values()) { col.add(r.getInstance()); } } // Notify first, so translator-type listeners, who react by registering a source // do not cause infinite loop. listener.schemaSourceRegistered(col); listeners.add(ret); } return ret; }
From source file:edu.byu.nlp.al.ActiveMeasurementSelector.java
/** * @param modelBuilder/* ww w. jav a2s.c o m*/ * @param annotations */ public ActiveMeasurementSelector(MeasurementModelBuilder modelBuilder, Dataset dataset, EmpiricalAnnotations<SparseFeatureVector, Integer> annotations, int numSamples, String trainingOperations, double thinningRate, int minCandidates, RandomGenerator rnd) { this.modelBuilder = modelBuilder; this.numSamples = numSamples; this.dataset = dataset; this.rnd = rnd; this.trainingOperations = trainingOperations; this.thinningRate = thinningRate; this.minCandidates = minCandidates; // we want to add all measurements that are not already taken (used as seed set contained in dataset) // FIXME: this is horrifically inefficient! Fix it! for (FlatInstance<SparseFeatureVector, Integer> meas : annotations.getMeasurements()) { if (!dataset.getMeasurements().contains(meas)) { candidates.add(meas); } } for (Multimap<Integer, FlatInstance<SparseFeatureVector, Integer>> perAnnotatorAnnotations : annotations .getPerInstancePerAnnotatorAnnotations().values()) { for (FlatInstance<SparseFeatureVector, Integer> meas : perAnnotatorAnnotations.values()) { candidates.add(meas); } } }
From source file:org.opentestsystem.shared.security.service.AbsractRolesAndPermissionsService.java
protected Multimap<String, SbacRole> extractUserRoles(final String[] pipeDelimitedTenancyChains, final Map<String, RoleToPermissionMapping> roleToPermissionMappings) { LOGGER.debug("tenantChain: " + pipeDelimitedTenancyChains); List<String[]> roleStringsDelimited = new ArrayList<String[]>(); for (final String roleChain : pipeDelimitedTenancyChains) { if (StringUtils.isNotEmpty(roleChain)) { roleStringsDelimited.add(roleChain.split("[|]", -1)); }//w w w .j a v a2 s .c om } final Multimap<String, SbacRole> userRoles = buildRolesFromParsedStrings(roleToPermissionMappings, roleStringsDelimited); setupEffectiveTenantsForRoles(Lists.newArrayList(userRoles.values())); return userRoles; }