protected MultiValuedMap<String, String> splitKeyValues(String params, String separator) { MultiValuedMap<String, String> data = new ArrayListValuedHashMap<>(); for (String line: params.split("\\r?\\n")) { String[] values = line.split(separator, 2); if (values.length == 2) { data.put(values[0].trim(), values[1].trim()); } } return data; }
/** * Gets a Collection from <code>MultiValuedMap</code> in a null-safe manner. * * @param <K> the key type * @param <V> the value type * @param map the {@link MultiValuedMap} to use * @param key the key to look up * @return the Collection in the {@link MultiValuedMap}, or null if input map is null */ public static <K, V> Collection<V> getCollection(final MultiValuedMap<K, V> map, final K key) { if (map != null) { return map.get(key); } return null; }
@Override public Set<K> keySet() { return decorated().keySet(); }
prismSchemaDescriptions.forEach(sd -> schemasByNamespace.put(sd.getNamespace(), sd)); List<String> fragmentedNamespaces = schemasByNamespace.keySet().stream() .filter(ns -> schemasByNamespace.get(ns).size() > 1) .collect(Collectors.toList()); LOGGER.trace("Fragmented namespaces: {}", fragmentedNamespaces); Collection<SchemaDescription> fragments = schemasByNamespace.get(namespace); LOGGER.trace("Parsing {} schemas for fragmented namespace {}", fragments.size(), namespace); for (SchemaDescription schemaDescription : fragments) {
annotationsInWindow.stream() .filter(fs -> fs.getFeatureValueAsString(feat) != null) .forEach(fs -> annotations.put(new Offset(fs.getBegin(), fs.getEnd()), fs)); List<Offset> sortedAnnotationKeys = new ArrayList<>(annotations.keySet()); sortedAnnotationKeys .sort(comparingInt(Offset::getBegin).thenComparingInt(Offset::getEnd)); if (suggestions.isEmpty() || annotations.isEmpty()) { continue; for (AnnotationFS annotation : annotations.get(oi.getB())) { String label = annotation.getFeatureValueAsString(feat); for (AnnotationSuggestion suggestion : group) {
modificationsForId.put(id, modification); iterator.remove(); modificationsForId.values().forEach(mod -> offspring.addModification(mod)); rv.offsprings.add(offspring); } else { for (Long id : modificationsForId.keySet()) { ObjectDeltaImpl<O> offspring = createOffspring(); modificationsForId.get(id).forEach(mod -> offspring.addModification(mod)); rv.offsprings.add(offspring);
socketIdToRequests.put(id, req); remainingAttemptDurations.add(attemptDuration); while (!socketIdToRequests.isEmpty() && !remainingAttemptDurations.isEmpty()) { for (UdpRequest req : socketIdToRequests.values()) { int id = addressToSocketId.get(req.getSourceAddress()); Iterator<UdpRequest> it = socketIdToRequests.get(id).iterator(); while (it.hasNext()) { UdpRequest pendingReq = it.next();
protected String[] getFeaturesForType(Type t) { if (!programmaticFeatures.containsKey(t.toString())) { return new String[0]; } String[] r = new String[programmaticFeatures.get(t.toString()).size()]; int i = 0; for (String f : programmaticFeatures.get(t.toString())) { r[i++] = f; } return r; }
@Test void Should_Use_User_Constructor_Parameters() { // given final Class[] classesToTest = { ClassWithSyntheticConstructor.class }; final ConstructorParameters parameters = new ConstructorParameters(new Object[]{ "string" }, new Class[]{ String.class }); final MultiValuedMap<Class<?>, ConstructorParameters> constructorParameters = spy(new ArrayListValuedHashMap<>()); constructorParameters.put(ClassWithSyntheticConstructor.class, parameters); final ConstructorTester constructorTester = new ConstructorTester(); constructorTester.setUserDefinedConstructors(constructorParameters); // when final Throwable result = catchThrowable(() -> constructorTester.testAll(classesToTest)); // then assertThat(result).isNull(); verify(constructorParameters).get(ClassWithSyntheticConstructor.class); }
/** * Initializes the index with a list of header names in proper encounter * order. * "Proper encounter order" means the order in which they are expected to be * found in the input CSV. Header names may be listed more than once if the * destination field is annotated with {@link CsvBindAndJoinByPosition} or * {@link CsvBindAndJoinByName}. Values of {@code null} indicate the column * from the input should not be mapped to a bean field. * * @param header A list of header names in the order in which they are * expected in the CSV input */ public void initializeHeaderIndex(String[] header) { positionToHeader = header != null ? ArrayUtils.clone(header): new String[0]; headerToPosition.clear(); int i = 0; while(i < positionToHeader.length) { headerToPosition.put(header[i], i); i++; } }
@Override public String debugDump(int indent) { StringBuilder sb = new StringBuilder(); DebugUtil.indentDebugDump(sb, indent); sb.append("SchemaRegistry:"); sb.append(" Parsed Schemas:"); for (String namespace: parsedSchemas.keySet()) { sb.append("\n"); DebugUtil.indentDebugDump(sb, indent + 1); sb.append(namespace); sb.append(": "); sb.append(parsedSchemas.get(namespace)); } return sb.toString(); }
@Override protected void processCSVRecordRow(@Nonnull final CSVRecord row, @Nonnull final Vocabulary vocabulary) { // The annotation source file contains data for several disorder databases. Only want to look at data that is // relevant for the current vocabulary. final String dbName = getRowItem(row, VOCABULARY_ID_COLUMN); if (StringUtils.isNotBlank(dbName)) { String diseaseId = getRowItem(row, TERM_ID_COLUMN); final String symptomId = getRowItem(row, PHENOTYPE_COLUMN); if (StringUtils.isNotBlank(diseaseId) && StringUtils.isNotBlank(symptomId)) { diseaseId = vocabularyIdToTermPrefix(dbName) + diseaseId; MultiValuedMap<String, String> termData = this.data.get(diseaseId); if (termData == null) { termData = new HashSetValuedHashMap<>(); this.data.put(diseaseId, termData); } termData.put(getDirectPhenotypesLabel(), symptomId); termData.putAll(getAllAncestorPhenotypesLabel(), getSelfAndAncestorTermIds(symptomId)); } } }
if (CollectionUtils.isEmpty(recommenderScoreMap.keys())) { log.error("No evaluation data for the learning curve. Project: {}", model.getObject().getProject()); StringBuilder chartType = new StringBuilder(); for (String key : recommenderScoreMap.keySet()) { String data = recommenderScoreMap.get(key).stream().map(Object::toString).collect(Collectors.joining(", "));
public void removePredictions(Recommender aRecommender) { // Remove incoming predictions if (incomingPredictions != null) { incomingPredictions.removePredictions(aRecommender.getId()); } // Remove active predictions if (activePredictions != null) { activePredictions.removePredictions(aRecommender.getId()); } // Remove trainedModel contexts.remove(aRecommender); // Remove from activeRecommenders map. // We have to do this, otherwise training and prediction continues for the // recommender when a new task is triggered. MultiValuedMap<AnnotationLayer, Recommender> newActiveRecommenders = new HashSetValuedHashMap<>(); MapIterator<AnnotationLayer, Recommender> it = activeRecommenders.mapIterator(); while (it.hasNext()) { AnnotationLayer layer = it.next(); Recommender rec = it.getValue(); if (!rec.equals(aRecommender)) { newActiveRecommenders.put(layer, rec); } } setActiveRecommenders(newActiveRecommenders); } }
@Override public Collection<V> values() { return decorated().values(); }
@Override public boolean putAll(final MultiValuedMap<? extends K, ? extends V> map) { if (map == null) { throw new NullPointerException("Map must not be null."); } boolean changed = false; for (final Map.Entry<? extends K, ? extends V> entry : map.entries()) { changed |= put(entry.getKey(), entry.getValue()); } return changed; }
/** * Null-safe check if the specified <code>MultiValuedMap</code> is empty. * <p> * If the provided map is null, returns true. * * @param map the map to check, may be null * @return true if the map is empty or null */ public static boolean isEmpty(final MultiValuedMap<?, ?> map) { return map == null || map.isEmpty(); }
@Override public void extendTerm(VocabularyInputTerm term, Vocabulary vocabulary) { MultiValuedMap<String, String> termData = this.data.get(term.getId()); if (termData == null || termData.isEmpty()) { return; } for (Map.Entry<String, Collection<String>> datum : termData.asMap().entrySet()) { if (!datum.getValue().isEmpty()) { term.set(datum.getKey(), datum.getValue()); } } }