List of usage examples for com.google.common.collect Multimap containsKey
boolean containsKey(@Nullable Object key);
From source file:org.sosy_lab.cpachecker.cpa.constraints.refiner.precision.ConstraintBasedConstraintsPrecision.java
private boolean constraintWithSameMeaningExists(final CFANode pLoc, final Constraint pConstraint, final Multimap<CFANode, Constraint> pTrackedConstraints) { if (pTrackedConstraints.containsKey(pLoc)) { final Collection<Constraint> constraintsOnLocation = pTrackedConstraints.get(pLoc); for (Constraint c : constraintsOnLocation) { if (SymbolicValues.representSameCCodeExpression(c, pConstraint)) { return true; }// w w w. j a va 2 s .c o m } } return false; }
From source file:cherry.foundation.testtool.stub.StubConfigurer.java
public void configure() throws IOException { for (Resource r : resources) { if (!r.exists()) { continue; }//from w w w . j av a 2 s . c o m try (InputStream in = r.getInputStream()) { Map<Class<?>, Map<String, Object>> map = objectMapper.readValue(in, new TypeReference<LinkedHashMap<Class<?>, Map<String, Object>>>() { }); for (Map.Entry<Class<?>, Map<String, Object>> entry : map.entrySet()) { Multimap<String, Method> methodMap = createMethodMap(entry.getKey().getDeclaredMethods()); for (Map.Entry<String, Object> ent : entry.getValue().entrySet()) { if (!methodMap.containsKey(ent.getKey())) { continue; } for (Method method : methodMap.get(ent.getKey())) { JavaType type = objectMapper.getTypeFactory() .constructType(method.getGenericReturnType()); List<Config> cfglist = parseConfig(ent.getValue()); for (Config cfg : cfglist) { Object v = parseValue(cfg, type); if (cfglist.size() == 1) { repository.get(method).alwaysReturn(v); } else { repository.get(method).thenReturn(v); } } } } } } } }
From source file:org.terasology.config.InputConfig.java
/** * Returns whether an input bind has been registered with the InputConfig. * It may just have trivial None input./*from w w w . j a v a 2 s . c o m*/ * * @param packageName The name of the bind's package * @param id The id of the bind * @return Whether the given bind has been registered with the InputConfig */ public boolean hasInputs(String packageName, String id) { Multimap<String, Input> packageMap = getPackageMap(packageName); if (packageMap != null) { return packageMap.containsKey(id); } return false; }
From source file:uk.ac.ebi.mdk.service.loader.data.ChEBIDataLoader.java
public String getFormula(String accession, Collection<DataValue> values) { Set<DataValue> formulae = new HashSet<DataValue>(); for (DataValue value : values) { if (value.type.equals("FORMULA") && !value.value.equals(".")) { formulae.add(value);/* ww w . j a v a 2 s .c o m*/ } } if (formulae.isEmpty()) return ""; // single entry if (formulae.size() == 1) { return formulae.iterator().next().value; } // resolve duplicates Multimap<String, DataValue> sourceMap = HashMultimap.create(); for (DataValue value : formulae) { sourceMap.put(value.source, value); } if (sourceMap.size() != 1 && sourceMap.containsKey("ChEBI")) { Collection<DataValue> chebiFormulae = sourceMap.get("ChEBI"); if (chebiFormulae.size() == 1) { return chebiFormulae.iterator().next().value; } else if (chebiFormulae.size() == 2) { // if there are two from ChEBI, favour the one with the R group Iterator<DataValue> it = chebiFormulae.iterator(); DataValue first = it.next(); DataValue second = it.next(); if (first.value.contains("R") && !second.value.contains("R")) { return first.value; } else if (second.value.contains("R") && !first.value.contains("R")) { return second.value; } } } LOGGER.warn("Could not resolve single formula for: " + accession + " : " + formulae); // just use the first one return formulae.iterator().next().value; }
From source file:org.opennms.features.topology.plugins.topo.linkd.internal.BridgeLinkStatusProvider.java
@Override protected List<EdgeAlarmStatusSummary> getEdgeAlarmSummaries(List<Integer> linkIds) { //Bridge Links are different, don't need the linkIds Multimap<String, EdgeAlarmStatusSummary> summaryMap = HashMultimap.create(); for (BridgeMacTopologyLink link : m_multimapLinks.values()) { String key = link.getNodeId() + ":" + link.getBridgePortIfIndex(); if (!summaryMap.containsKey(key)) { summaryMap.put(key, new EdgeAlarmStatusSummary(link.getNodeId(), link.getBridgePort(), null)); }/*from w w w.jav a 2 s . co m*/ if (link.getTargetNodeId() != null && link.getSourceIfIndex() != null) { summaryMap.put(link.getTargetNodeId() + ":" + link.getSourceIfIndex(), new EdgeAlarmStatusSummary(link.getNodeId(), link.getTargetNodeId(), null)); } } List<OnmsAlarm> alarms = getLinkDownAlarms(); for (OnmsAlarm alarm : alarms) { String key = alarm.getNodeId() + ":" + alarm.getIfIndex(); String cloudKey = alarm.getNodeId() + "|" + alarm.getIfIndex(); if (summaryMap.containsKey(key)) { Collection<EdgeAlarmStatusSummary> summaries = summaryMap.get(key); if (m_multimapLinks.containsKey(cloudKey)) { for (BridgeMacTopologyLink link : m_multimapLinks.get(cloudKey)) { String indexKey = link.getTargetNodeId() + ":" + link.getSourceIfIndex(); summaries.addAll(summaryMap.get(indexKey)); } } for (EdgeAlarmStatusSummary summary : summaries) { summary.setEventUEI(alarm.getUei()); } } } List<EdgeAlarmStatusSummary> ret_val = new ArrayList<EdgeAlarmStatusSummary>(); for (String summaryMapKey : summaryMap.keySet()) { ret_val.addAll(summaryMap.get(summaryMapKey)); } return ret_val; }
From source file:edu.umn.msi.tropix.client.search.impl.TropixSearchClientImpl.java
private List<GridData> transform(final Data[] inputData, final String serviceUrl) { final Data[] data = inputData == null ? new Data[0] : inputData; final List<GridData> results = new ArrayList<GridData>(data.length); Collections.transform(Arrays.asList(data), getConversionFunction(serviceUrl), results); final Multimap<String, GridData> gridDataByOwnerMap = HashMultimap.create(); for (final GridData gridData : results) { gridDataByOwnerMap.put(gridData.getOwnerId(), gridData); }/*w w w . j a v a2s. co m*/ for (final GridUser user : gridUserIterable) { if (gridDataByOwnerMap.containsKey(user.getGridId())) { for (final GridData gridData : gridDataByOwnerMap.get(user.getGridId())) { gridData.setUserName(user.toString()); } } } return results; }
From source file:org.jclouds.fujitsu.fgcp.filters.RequestAuthenticator.java
@VisibleForTesting HttpRequest addQueryParamsToRequest(HttpRequest request, String accessKeyId, String signature, String lang) { Multimap<String, String> decodedParams = queryParser().apply(request.getEndpoint().getRawQuery()); Builder<?> builder = request.toBuilder().endpoint(request.getEndpoint()).method(request.getMethod()); if (!decodedParams.containsKey("Version")) { builder.addQueryParam(RequestParameters.VERSION, apiVersion); }//from w w w . j a va 2 s .co m builder.addQueryParam(RequestParameters.LOCALE, lang) .addQueryParam(RequestParameters.ACCESS_KEY_ID, accessKeyId) .addQueryParam(RequestParameters.SIGNATURE, signature); return builder.build(); }
From source file:net.diogobohm.timed.api.ui.domain.builder.OverviewBuilder.java
public Overview build(Date startDate, Date endDate, List<Task> tasks) { Date safeEndDate = getSafeEndDate(endDate); List<DayTaskList> dayTasks = Lists.newArrayList(); Multimap<LocalDate, Task> dayTaskMap = createDayTaskMap(tasks); LocalDate startDay = LocalDate.fromDateFields(startDate); LocalDate endDay = LocalDate.fromDateFields(safeEndDate); for (LocalDate curDay = startDay; !curDay.isAfter(endDay); curDay = curDay.plusDays(1)) { List<Task> curDayTasks = Lists.newArrayList(); if (dayTaskMap.containsKey(curDay)) { curDayTasks.addAll(dayTaskMap.get(curDay)); }// www . ja v a 2 s . co m dayTasks.add(new DayTaskList(curDay.toDate(), new TaskList(curDayTasks))); } return new Overview(dayTasks); }
From source file:org.jboss.errai.idea.plugin.ui.inspection.UiDataFieldIsValidInspection.java
public static void ensureDataFieldIsValid(ProblemsHolder holder, PsiAnnotation annotation) { final TemplateMetaData templateMetaData = TemplateUtil.getTemplateMetaData(annotation); if (templateMetaData == null) { return;/*from w w w. j av a2s .c o m*/ } final Multimap<String, TemplateDataField> allDataFieldTags = templateMetaData .getAllDataFieldsInTemplate(false); final PsiElement ownerElement = Util.getImmediateOwnerElement(annotation); final AnnotationValueElement annotationValue = Util.getValueStringFromAnnotationWithDefault(annotation); if (annotationValue == null) { return; } final TemplateUtil.DataFieldExistence dataFieldExistence = TemplateUtil.dataFieldExistenceCheck(annotation, templateMetaData); final AnnotationValueElement annoValueEl = Util.getValueStringFromAnnotationWithDefault(annotation); final String annoValue = annoValueEl.getValue(); if (dataFieldExistence != TemplateUtil.DataFieldExistence.EXISTS) { if (dataFieldExistence == TemplateUtil.DataFieldExistence.OUT_OF_SCOPE) { holder.registerProblem(annoValueEl.getLogicalElement(), "Data-field is out of scope (it is not an descendant of the template root node)"); } else { holder.registerProblem(annoValueEl.getLogicalElement(), "Cannot resolve data-field: " + annoValueEl.getValue()); } return; } if (!allDataFieldTags.containsKey(annotationValue.getValue())) { holder.registerProblem(annotationValue.getLogicalElement(), "No corresponding data-field element in template: " + annotationValue.getValue()); } final PsiClass typeOfElement = Util.getTypeOfElement(ownerElement); if (!Util.typeIsAssignableFrom(typeOfElement, Types.GWT_ELEMENT_TYPE, Types.GWT_WIDGET_TYPE)) { holder.registerProblem(ownerElement, "Type is not a valid template part (must be Element or Widget)"); } }
From source file:net.shibboleth.idp.saml.saml1.profile.impl.FilterByQueriedAttributeDesignators.java
/** {@inheritDoc} */ @Override/*from w w w . j a v a2 s .com*/ protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) { final Collection<IdPAttribute> keepers = new ArrayList<>(query.getAttributeDesignators().size()); final Multimap<String, IdPAttribute> mapped = mapperService.mapAttributes(query.getAttributeDesignators()); log.debug("Query content mapped to attribute IDs: {}", mapped.keySet()); for (final IdPAttribute attribute : attributeContext.getIdPAttributes().values()) { if (mapped.containsKey(attribute.getId())) { log.debug("Retaining attribute '{}' requested by query", attribute.getId()); keepers.add(attribute); } else { log.debug("Removing attribute '{}' not requested by query", attribute.getId()); } } attributeContext.setIdPAttributes(keepers); }