List of usage examples for com.google.common.collect Multimap values
Collection<V> values();
From source file:com.gf.components.reflections.ReflectionsScanner.java
private Set<Class<?>> findAbsoluteSubTypes(Multimap<String, String> map, Class<?> parentClass) { HashSet<Class<?>> out = new HashSet<Class<?>>(); HashSet<String> processed = new HashSet<String>(); Collection<String> values = map.values(); for (String candidat : values) { if (processed.contains(candidat)) { continue; }// www . j a v a 2 s .c o m try { Class<?> clazz = Class.forName(candidat); if (parentClass.isAssignableFrom(clazz)) { out.add(clazz); } } catch (ClassNotFoundException e) { log.error("can't get class by name " + candidat, e); } processed.add(candidat); } return out; }
From source file:edu.byu.nlp.al.RandomMeasurementSelector.java
/** * @param modelBuilder/*from www. j av a 2s.c o m*/ * @param annotations */ public RandomMeasurementSelector(MeasurementModelBuilder modelBuilder, Dataset dataset, EmpiricalAnnotations<SparseFeatureVector, Integer> annotations, RandomGenerator rnd) { // 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); } } Collections.shuffle(candidates, new RandomAdaptor(rnd)); }
From source file:org.robotframework.ide.eclipse.main.plugin.search.participants.TargetedSearch.java
public final void run(final IProgressMonitor monitor, final Multimap<IProject, LibrarySpecification> libraries, final Set<IFile> files) throws OperationCanceledException { monitor.beginTask("Searching for '" + searchPattern.getPattern() + "'", libraries.values().size() + files.size()); for (final IProject project : libraries.keySet()) { for (final LibrarySpecification librarySpecification : libraries.get(project)) { if (monitor.isCanceled()) { throw new OperationCanceledException(); }/* w w w .j av a2s . c o m*/ monitor.subTask("locating matches in " + librarySpecification.getName() + " library used by '" + project.getName() + "' project"); locateMatchesInLibrarySpecification(project, librarySpecification); for (final KeywordSpecification keywordSpecification : librarySpecification.getKeywords()) { locateMatchesInKeywordSpecification(project, librarySpecification, keywordSpecification); } monitor.worked(1); } } for (final IFile file : files) { if (monitor.isCanceled()) { throw new OperationCanceledException(); } locateMatchesInRobotFile(model.createSuiteFile(file)); monitor.worked(1); } }
From source file:ch.thn.datatree.core.GenericMapTreeNode.java
@Override public boolean addChildNodes(Multimap<K, N> nodes) { if (map.putAll(nodes)) { for (N node : nodes.values()) { node.internalSetParentNode(internalGetThis(), true); fireNodeEvent(TreeEventType.CHILD_ADDED, node, internalGetThis(), node.getNodeIndex(), null); }// ww w . j a va 2 s .c o m return true; } return false; }
From source file:me.lucko.luckperms.common.model.NodeMap.java
void setContent(Multimap<ImmutableContextSet, ? extends Node> multimap) { setContent(multimap.values()); }
From source file:com.dangdang.ddframe.rdb.sharding.merger.groupby.GroupByResultSet.java
private Collection<GroupByValue> reduce(final Multimap<GroupByKey, GroupByValue> mappedResult) throws SQLException { List<GroupByValue> result = new ArrayList<>(mappedResult.values().size() * columnLabels.size()); for (GroupByKey key : mappedResult.keySet()) { Collection<GroupByValue> each = mappedResult.get(key); GroupByValue reduceResult = new GroupByValue(); for (int i = 0; i < columnLabels.size(); i++) { int index = i + 1; Optional<AggregationColumn> aggregationColumn = findAggregationColumn(index); Comparable<?> value = null; if (aggregationColumn.isPresent()) { value = aggregate(aggregationColumn.get(), index, each); }/*from w w w . ja v a2s . c o m*/ value = null == value ? each.iterator().next().getValue(new ResultSetQueryIndex(index)) : value; reduceResult.put(index, columnLabels.get(i), value); } if (orderByColumns.isEmpty()) { reduceResult.addGroupByColumns(groupByColumns); } else { reduceResult.addOrderColumns(orderByColumns); } result.add(reduceResult); } Collections.sort(result); log.trace("Reduced result: {}", result); return result; }
From source file:org.eclipse.xtext.mwe.RuntimeResourceSetInitializer.java
public ResourceSet getInitializedResourceSet(List<String> pathes, UriFilter filter) { ResourceSet resourceSet = resourceSetProvider.get(); Multimap<String, URI> pathToUriMap = getPathToUriMap(pathes, filter); IAllContainersState containersState = factory.getContainersState(pathes, pathToUriMap); resourceSet.eAdapters().add(new DelegatingIAllContainerAdapter(containersState)); for (URI uri : pathToUriMap.values()) { resourceSet.createResource(uri); }/*w w w . j a v a2 s. c o m*/ return resourceSet; }
From source file:io.redlink.sdk.impl.analysis.model.Entity.java
/** * Get all literal values for the property passed by parameter * * @param property Property URI// www . ja va 2 s .c o m * @return */ public Collection<String> getValues(String property) { Multimap<Optional<String>, String> values = properties.get(property); if (values == null) { return Collections.emptyList(); } return values.values(); }
From source file:com.b2international.snowowl.snomed.core.ecl.SnomedEclRefinementEvaluator.java
static Function<Collection<Property>, Collection<Property>> filterByCardinality( final boolean grouped, final Range<Long> groupCardinality, final Range<Long> cardinality, final Function<Property, Object> idProvider) { return matchingProperties -> { final Multimap<Object, Property> propertiesByMatchingIds = Multimaps.index(matchingProperties, idProvider);/*from ww w .j a v a 2s. c om*/ final Collection<Property> properties = newHashSet(); final Range<Long> allowedRelationshipCardinality; if (grouped) { final long minRelationships = groupCardinality.lowerEndpoint() == 0 ? cardinality.lowerEndpoint() : groupCardinality.lowerEndpoint() * cardinality.lowerEndpoint(); final long maxRelationships; if (groupCardinality.hasUpperBound() && cardinality.hasUpperBound()) { if (groupCardinality.upperEndpoint() == Long.MAX_VALUE || cardinality.upperEndpoint() == Long.MAX_VALUE) { maxRelationships = Long.MAX_VALUE; } else { maxRelationships = groupCardinality.upperEndpoint() * cardinality.upperEndpoint(); } } else { // group and relationship cardinalities are unbounded maxRelationships = Long.MAX_VALUE; } allowedRelationshipCardinality = Range.closed(minRelationships, maxRelationships); } else { allowedRelationshipCardinality = cardinality; } for (Object matchingConceptId : propertiesByMatchingIds.keySet()) { final Collection<Property> propertiesOfConcept = propertiesByMatchingIds.get(matchingConceptId); if (allowedRelationshipCardinality.contains((long) propertiesOfConcept.size())) { if (grouped) { final Multimap<Integer, Property> indexedByGroup = FluentIterable.from(propertiesOfConcept) .index(Property::getGroup); // if groups should be considered as well, then check group numbers in the matching sets // check that the concept has at least the right amount of groups final Multimap<Integer, Property> validGroups = ArrayListMultimap.create(); for (Integer group : indexedByGroup.keySet()) { final Collection<Property> groupedRelationships = indexedByGroup.get(group); if (cardinality.contains((long) groupedRelationships.size())) { validGroups.putAll(group, groupedRelationships); } } if (groupCardinality.contains((long) validGroups.keySet().size())) { properties.addAll(validGroups.values()); } } else { properties.addAll(propertiesOfConcept); } } } return properties; }; }
From source file:springfox.documentation.swagger2.mappers.ModelMapper.java
Map<String, Model> modelsFromApiListings(Multimap<String, ApiListing> apiListings) { Map<String, springfox.documentation.schema.Model> definitions = newHashMap(); for (ApiListing each : apiListings.values()) { definitions.putAll(each.getModels()); }/*from w w w. j av a2s. c om*/ return mapModels(definitions); }