List of usage examples for com.google.common.collect Multimap get
Collection<V> get(@Nullable K key);
From source file:org.jclouds.http.HttpMessage.java
/** * try to get the value, then try as lowercase. *//*from w w w.java2 s. c o m*/ public String getFirstHeaderOrNull(String string) { Collection<String> values = headers.get(string); if (values.size() == 0) { Multimap<String, String> lowerCaseHeaders = Multimaps2.transformKeys(getHeaders(), new ToLowerCase()); values = lowerCaseHeaders.get(string.toLowerCase()); } return (values.size() >= 1) ? values.iterator().next() : null; }
From source file:org.tensorics.core.tensor.operations.OngoingMapOut.java
public <C1> Tensor<Map<C1, V>> inDirectionOf(Class<? extends C1> dimension) { Builder<Map<C1, V>> tensorBuilder = ImmutableTensor .builder(OngoingMapOut.dimensionsExcept(tensor.shape().dimensionSet(), dimension)); tensorBuilder.context(tensor.context()); // XXX IS this correct? Multimap<Set<?>, Entry<Position, V>> fullEntries = groupBy(TensorInternals.mapFrom(tensor).entrySet(), dimension);/*from w w w . j a v a 2 s . co m*/ for (Set<?> key : fullEntries.keySet()) { Map<C1, V> values = mapByDimension(fullEntries.get(key), dimension); tensorBuilder.put(Position.of(key), values); } return tensorBuilder.build(); }
From source file:com.griddynamics.jagger.storage.rdb.OneTableJdbcKeyValueStorage.java
@Override public void putAll(Namespace namespace, Multimap<String, Object> valuesMap) { StringBuilder sb = new StringBuilder(); for (String key : valuesMap.keySet()) { for (Object value : valuesMap.get(key)) { sb.append("insert into "); sb.append("TABLE_NAME "); sb.append(" (name, key, value) values "); sb.append("("); sb.append(SerializationUtils.serialize(value)); sb.append(namespace);/* w ww . jav a 2s .co m*/ sb.append(","); sb.append(key); sb.append(","); sb.append(")"); sb.append(","); } } jdbcTemplate.update(sb.toString().substring(0, sb.length() - 1)); }
From source file:org.opencms.ui.actions.CmsUserInfoDialogAction.java
/** * @see org.opencms.ui.actions.I_CmsWorkplaceAction#executeAction(org.opencms.ui.I_CmsDialogContext) *//*from ww w. j a v a2s . c om*/ public void executeAction(final I_CmsDialogContext context) { CmsUserInfo dialog = new CmsUserInfo(new I_UploadListener() { public void onUploadFinished(List<String> uploadedFiles) { handleUpload(uploadedFiles, context); } }, context); Multimap<String, String> params = A_CmsUI.get().getParameters(); int top = 55; int left = 0; if (params.containsKey("left")) { String buttonLeft = params.get("left").iterator().next(); left = Integer.parseInt(buttonLeft) - 290; } final Window window = new Window(); window.setModal(false); window.setClosable(true); window.setResizable(false); window.setContent(dialog); context.setWindow(window); window.addStyleName(OpenCmsTheme.DROPDOWN); UI.getCurrent().addWindow(window); window.setPosition(left, top); }
From source file:nars.op.mental.Anticipate.java
protected void mayHaveHappenedAsExpected(@NotNull Task c) { if (!c.isInput() || c.isEternal()) { return; //it's not a input task, the system is not allowed to convince itself about the state of affairs ^^ }// w w w .ja v a 2 s . c o m float freq = c.freq(); long cOccurr = c.occurrence(); final List<Task> toRemove = this.toRemove; int tolerance = nar.duration(); Multimap<Compound, Task> a = this.anticipations; Compound ct = c.term(); a.get(ct).stream().filter(tt -> inTime(freq, tt, cOccurr, tolerance)).forEach(tt -> { toRemove.add(tt); happeneds++; }); toRemove.forEach(tt -> a.remove(ct, tt)); toRemove.clear(); }
From source file:org.rf.ide.core.testdata.model.table.RobotElementsComparatorWithPositionChangedPresave.java
@Override public int compare(final IRobotLineElement o1, final IRobotLineElement o2) { int result = ECompareResult.EQUAL_TO.getValue(); final Optional<IRobotTokenType> o1TypeOP = findType(o1); final Optional<IRobotTokenType> o2TypeOP = findType(o2); final int posComperatorResult = posComperator.compare(o1, o2); if (o1TypeOP.isPresent() && o2TypeOP.isPresent()) { if (o1TypeOP.get() == o2TypeOP.get()) { final Multimap<IRobotLineElement, Integer> indexes = indexesOf(typeToTokens.get(o1TypeOP.get()), o1, o2);//w w w. j a v a2 s.c o m final Collection<Integer> o1PosInSequence = indexes.get(o1); final Collection<Integer> o2PosInSequence = indexes.get(o2); final Integer o1Index = o1PosInSequence.toArray(new Integer[o1PosInSequence.size()])[0]; final Integer o2Index = o2PosInSequence.toArray(new Integer[o2PosInSequence.size()])[0]; result = Integer.compare(o1Index, o2Index); } else { final Integer typeO1hierarchy = typesToHierarchy.get(o1TypeOP.get()); final Integer typeO2hierarchy = typesToHierarchy.get(o2TypeOP.get()); result = Integer.compare(typeO1hierarchy, typeO2hierarchy); if (posComperatorResult != ECompareResult.EQUAL_TO.getValue()) { if (isBothWithPositionSet(o1, o2)) { result = posComperatorResult; } } } } else if (!o1TypeOP.isPresent() && !o2TypeOP.isPresent()) { result = posComperatorResult; } else if (!o1TypeOP.isPresent()) { result = ECompareResult.LESS_THAN.getValue(); } else if (!o2TypeOP.isPresent()) { result = ECompareResult.GREATER_THAN.getValue(); } return result; }
From source file:com.google.api.explorer.client.embedded.EmbeddedParameterFormPresenter.java
/** * Returns the request body specified by the "resource" key of the parameters block specified. *//*from www . ja va 2s . c o m*/ private String getRequestBodyParam(Multimap<String, String> params) { Collection<String> body = params.get(UrlBuilder.BODY_QUERY_PARAM_KEY); return body.isEmpty() ? null : Iterables.getLast(body); }
From source file:com.proofpoint.jmx.JmxInspector.java
private void addConfig(Multimap<String, String> nameMap, Class<?> clazz, ImmutableSortedSet.Builder<InspectorRecord> builder) throws InvocationTargetException, IllegalAccessException { Collection<String> thisNameList = nameMap.get(clazz.getName()); if (thisNameList != null) { for (Method method : clazz.getMethods()) { Managed configAnnotation = method.getAnnotation(Managed.class); if (configAnnotation != null) { for (String thisName : thisNameList) { builder.add(new InspectorRecord(thisName, method.getName(), configAnnotation.description(), getType(method))); }/* www. java 2 s .co m*/ } } } }
From source file:tterrag.potionapi.common.util.ReplaceUtil.java
@SubscribeEvent(priority = EventPriority.HIGHEST) public void onWorldLoad(WorldEvent.Load event) { if (Repl.replacements.size() < 1) { return;/*from w w w. j a va 2 s .com*/ } for (Map.Entry<RegistryNamespaced, Multimap<String, Object>> entry : Repl.replacements.entrySet()) { RegistryNamespaced reg = entry.getKey(); Multimap<String, Object> map = entry.getValue(); Iterator<String> v = map.keySet().iterator(); while (v.hasNext()) { String id = v.next(); List<Object> c = (List<Object>) map.get(id); int i = 0, e = c.size() - 1; Object end = c.get(e); if (reg.getIDForObject(c.get(0)) != reg.getIDForObject(end)) { for (; i <= e; ++i) { Object t = c.get(i); Object oldThing = reg.getObject(id); Repl.overwrite_do(reg, id, t, oldThing); Repl.alterDelegate(oldThing, end); } } } } }
From source file:org.obiba.opal.web.gwt.app.client.report.list.ReportsView.java
@Override public void setReportTemplates(JsArray<ReportTemplateDto> templates) { reportList.clear();//from www . j av a 2s. co m // group templates by project Multimap<String, ReportTemplateDto> templateMap = ArrayListMultimap.create(); for (ReportTemplateDto template : JsArrays.toIterable(JsArrays.toSafeArray(templates))) { templateMap.get(template.getProject()).add(template); } for (String project : templateMap.keySet()) { reportList.add(new NavHeader( TranslationsUtils.replaceArguments(translations.reportTemplatesHeader(), project))); addReportTemplateLinks(templateMap.get(project)); } }