List of usage examples for com.google.common.collect ListMultimap get
@Override List<V> get(@Nullable K key);
Because the values for a given key may have duplicates and follow the insertion ordering, this method returns a List , instead of the java.util.Collection specified in the Multimap interface.
From source file:com.google.gerrit.server.index.change.StalenessChecker.java
private static boolean refsAreStale(GitRepositoryManager repoManager, Change.Id id, Project.NameKey project, SetMultimap<Project.NameKey, RefState> allStates, ListMultimap<Project.NameKey, RefStatePattern> allPatterns) { try (Repository repo = repoManager.openRepository(project)) { Set<RefState> states = allStates.get(project); for (RefState state : states) { if (!state.match(repo)) { return true; }//from www . ja v a2s . co m } for (RefStatePattern pattern : allPatterns.get(project)) { if (!pattern.match(repo, states)) { return true; } } return false; } catch (IOException e) { log.warn(String.format("error checking staleness of %s in %s", id, project), e); return true; } }
From source file:org.sonar.server.rule.ws.ActiveRuleCompleter.java
private static Collection<String> writeActiveRules(RuleKey ruleKey, Collection<ActiveRuleDto> activeRules, ListMultimap<ActiveRuleKey, ActiveRuleParamDto> activeRuleParamsByActiveRuleKey, Rules.Actives.Builder activesBuilder) { Collection<String> qProfileKeys = newHashSet(); Rules.ActiveList.Builder activeRulesListResponse = Rules.ActiveList.newBuilder(); for (ActiveRuleDto activeRule : activeRules) { activeRulesListResponse.addActiveList( buildActiveRuleResponse(activeRule, activeRuleParamsByActiveRuleKey.get(activeRule.getKey()))); qProfileKeys.add(activeRule.getKey().qProfile()); }/*from w w w .j a v a 2 s . co m*/ activesBuilder.getMutableActives().put(ruleKey.toString(), activeRulesListResponse.build()); return qProfileKeys; }
From source file:org.obiba.onyx.quartz.editor.utils.QuestionnaireElementCloner.java
private static <T extends IQuestionnaireElement> ElementClone<T> createElementClone(T element, T elementCloned, LocaleProperties localeProperties) { ListMultimap<Locale, KeyValue> elementLabel = localeProperties.getElementLabels(element); ListMultimap<Locale, KeyValue> elementLabelClone = ArrayListMultimap.create(); if (elementLabel != null) { for (Locale locale : localeProperties.getLocales()) { List<KeyValue> keyValues = elementLabel.get(locale); for (KeyValue keyValue : keyValues) { elementLabelClone.put(locale, keyValue.duplicate()); }//from www . java 2 s . c o m } } LocaleProperties localePropertiesClone = new LocaleProperties(); localePropertiesClone.setLocales(new ArrayList<Locale>(localeProperties.getLocales())); localePropertiesClone.addElementLabel(elementCloned, elementLabelClone); return new ElementClone<T>(elementCloned, localePropertiesClone); }
From source file:com.griddynamics.jagger.monitoring.MonitoringAggregator.java
private static void differentiateRelativeParameters( ListMultimap<MonitoringStream, ? extends MonitoringStatistics> aggregatedData) { for (MonitoringStream stream : aggregatedData.keySet()) { if (stream.monitoringParameter.isCumulativeCounter()) { List<? extends MonitoringStatistics> trace = aggregatedData.get(stream); // trace is ordered by time if (!trace.isEmpty()) { for (int i = trace.size() - 1; i > 0; i--) { MonitoringStatistics statisticsBySuT = trace.get(i); MonitoringStatistics previousStatisticsBySuT = trace.get(i - 1); double diffValue = statisticsBySuT.getAverageValue() - previousStatisticsBySuT.getAverageValue(); if (diffValue < 0) { log.warn(//from ww w . ja v a 2s. c om "Negative cumulative metric has been flushed and will be removed. Difference with previous value by parameter {} is {}: ({} - {})", new Object[] { statisticsBySuT.getParameterId(), diffValue, statisticsBySuT.getAverageValue(), previousStatisticsBySuT.getAverageValue() }); trace.remove(i); } else { statisticsBySuT.setAverageValue(diffValue); } } trace.get(0).setAverageValue(0d); } } } }
From source file:org.icgc.dcc.portal.pql.convert.FiltersConverter.java
private static String resolveFirstNestedPath(Type indexType, String nestedPath, ListMultimap<String, JqlField> sortedFields) { val typeFilter = createTypeFilter(sortedFields.get(nestedPath), indexType); return isNestFilter(nestedPath, indexType) ? format(NESTED_TEMPLATE, resolveNestedPath(nestedPath, indexType), typeFilter) : typeFilter;//from w w w .j a v a2s . com }
From source file:org.icgc.dcc.portal.pql.convert.FiltersConverter.java
private static String resolveRestNestedPath(Type indexType, Pair<String, String> reduceValuePair, String nestedPath, ListMultimap<String, JqlField> sortedFields) { val filter = createTypeFilter(sortedFields.get(nestedPath), indexType); val reducedValue = unboxReduceValue(reduceValuePair); val previousSiblingPath = reduceValuePair.getSecond(); return isNestFilter(nestedPath, indexType) ? (isChildNesting(nestedPath, previousSiblingPath) ? format("nested(%s,and(%s,%s))", resolveNestedPath(nestedPath, indexType), reducedValue, filter)// w w w. j a v a 2 s.co m : format("nested(%s,%s),%s", nestedPath, filter, reducedValue)) : format("%s,%s", filter, reducedValue); }
From source file:exm.stc.tclbackend.TclTemplateProcessor.java
public static List<TclTree> processTemplate(String context, TclOpTemplate template, List<TemplateArg> inputs, List<TemplateArg> outputs) { // First work out what variable names map to what args ListMultimap<String, TemplateArg> argMap; argMap = buildArgMap(template, inputs, outputs); ArrayList<TclTree> result = new ArrayList<TclTree>(); // Now fill in template for (TemplateElem elem : template.getElems()) { if (elem.getKind() == ElemKind.TEXT) { String tok = StringUtil.tclTrim(elem.getText()); if (tok.length() > 0) { result.add(new Token(tok)); }/*ww w . j a v a 2 s. com*/ } else { List<TemplateArg> argVals = argMap.get(elem.getVarName()); for (TemplateArg argVal : argVals) { result.add(getExpr(context, elem.getVarName(), elem.getKind(), argVal)); } } } return result; }
From source file:com.google.gerrit.server.change.RelatedChangesSorter.java
private static Collection<PatchSetData> walkAncestors(ProjectControl ctl, ListMultimap<PatchSetData, PatchSetData> parents, PatchSetData start) throws OrmException { LinkedHashSet<PatchSetData> result = new LinkedHashSet<>(); Deque<PatchSetData> pending = new ArrayDeque<>(); pending.add(start);// w w w . ja v a 2 s. c om while (!pending.isEmpty()) { PatchSetData psd = pending.remove(); if (result.contains(psd) || !isVisible(psd, ctl)) { continue; } result.add(psd); pending.addAll(Lists.reverse(parents.get(psd))); } return result; }
From source file:org.caleydo.view.domino.api.model.typed.TypedSets.java
/** * compress the sets such that one idtype occurs only ones * * @param sets/* w w w. j a v a2 s. c om*/ * @return */ private static TypedSet[] compress(TypedSet[] sets, boolean union) { ListMultimap<IDType, TypedSet> index = Multimaps.index(Arrays.asList(sets), TypedCollections.TO_IDTYPE); if (index.keySet().size() == sets.length) // nothing to compress return sets; TypedSet[] new_ = new TypedSet[index.keySet().size()]; int i = 0; for (IDType idType : index.keySet()) { List<TypedSet> same = index.get(idType); new_[i++] = union ? TypedSet.union(same) : TypedSet.intersection(same); } return new_; }
From source file:org.apache.flex.compiler.internal.tree.mxml.MXMLDataBindingParser.java
/** * Builds a list of DataBindingFragmentList and NonDataBindingFragmentList * objects that organizes the fragments that are inside databindings and * outside databindings.// w w w .j a v a 2s . com */ private static List<FragmentList> split(ISourceFragment[] fragments, ListMultimap<ISourceFragment, Integer> scanResult) { List<FragmentList> result = new ArrayList<FragmentList>(); boolean inDataBinding = false; FragmentList currentList = null; for (ISourceFragment fragment : fragments) { // Get the character indexes where '{' and '}' for databindings are. List<Integer> braceIndices = scanResult.get(fragment); if (braceIndices == null) { if (currentList == null) currentList = newFragmentList(result, inDataBinding); // If there is no '{' or '}' in this fragment, // add the fragment to the current fragment list. currentList.add(fragment); } else { // Otherwise, we'll have to break up the fragment. // Add an end-of-fragment index at the end of the list // so that we don't miss the last subfragment. braceIndices.add(fragment.getLogicalText().length()); // Break up the fragment into subfragments around // the '{' and '}' characters. // Add each subfragment to the appropriate list. int beginIndex = 0; for (int braceIndex : braceIndices) { ISourceFragment subfragment = ((SourceFragment) fragment).subfragment(beginIndex, braceIndex); if (subfragment != null) { currentList = newFragmentList(result, inDataBinding); currentList.add(subfragment); } beginIndex = braceIndex + 1; inDataBinding = !inDataBinding; } } } return result; }