private List<Object> createArguments(Config configNode) { List<Object> arguments = new ArrayList<>(parameterValueProviders.size()); parameterValueProviders.forEach((name, propertyWrapper) -> { Config subConfig = configNode.get(name); Object argument = propertyWrapper .get(subConfig) .orElseThrow(() -> new ConfigMappingException(configNode.key(), type, "Missing value for parameter '" + name + "'.")); arguments.add(argument); }); return arguments; }
config.weights.forEach((routeId, weight) -> { Double nomalizedWeight = weight / (double) weightsSum; config.normalizedWeights.put(routeId, nomalizedWeight);
private LinkedHashMap<String, String> repositoryMap(boolean downloadInBuck) { LinkedHashMap<String, String> rawRepositories = new LinkedHashMap<>(); if (!downloadInBuck) { return rawRepositories; } addRepositories(getProject().getRootProject(), rawRepositories); getProject() .getRootProject() .getSubprojects() .forEach( subProject -> { addRepositories(subProject, rawRepositories); }); LinkedHashMap<String, String> filteredRepositories = new LinkedHashMap<>(); rawRepositories.forEach( (key, value) -> { if (!filteredRepositories.values().contains(value)) { // Skip adding any `file:` repositories since the path would be absolute // and will prevent from checking in the generated buckconfig file. if (!value.startsWith("file:")) { filteredRepositories.put(key, value); } } }); return filteredRepositories; }
sortedColumns.forEach((key, defn) -> { newColumns.put(key, defn); if (defn == afterColumn) {
private static void computeRulesFacet(Common.Facets.Builder wsFacets, Facets facets, SearchResponseData data) { LinkedHashMap<String, Long> facet = facets.get(PARAM_RULES); if (facet == null) { return; } Map<Integer, RuleKey> ruleIdsByRuleKeys = data.getRules().stream().collect(uniqueIndex(RuleDefinitionDto::getId, RuleDefinitionDto::getKey)); Common.Facet.Builder wsFacet = wsFacets.addFacetsBuilder(); wsFacet.setProperty(PARAM_RULES); facet.forEach((ruleId, count) -> wsFacet.addValuesBuilder() .setVal(ruleIdsByRuleKeys.get(Integer.parseInt(ruleId)).toString()) .setCount(count) .build()); wsFacet.build(); }
private static void computeProjectsFacet(Common.Facets.Builder wsFacets, Facets facets, SearchResponseData datas) { LinkedHashMap<String, Long> facet = facets.get(FACET_PROJECTS); if (facet == null) { return; } Common.Facet.Builder wsFacet = wsFacets.addFacetsBuilder(); wsFacet.setProperty(FACET_PROJECTS); facet.forEach((uuid, count) -> { ComponentDto component = datas.getComponentByUuid(uuid); requireNonNull(component, format("Component has not been found for uuid '%s'", uuid)); wsFacet.addValuesBuilder() .setVal(component.getKey()) .setCount(count) .build(); }); wsFacet.build(); }
private static void computeStandardFacet(Common.Facets.Builder wsFacets, Facets facets, String facetKey) { LinkedHashMap<String, Long> facet = facets.get(facetKey); if (facet == null) { return; } Common.Facet.Builder wsFacet = wsFacets.addFacetsBuilder(); wsFacet.setProperty(facetKey); facet.forEach((value, count) -> wsFacet.addValuesBuilder() .setVal(value) .setCount(count) .build()); wsFacet.build(); }
private static void computeAssigneesFacet(Common.Facets.Builder wsFacets, Facets facets, SearchResponseData data) { LinkedHashMap<String, Long> facet = facets.get(PARAM_ASSIGNEES); if (facet == null) { return; } Common.Facet.Builder wsFacet = wsFacets.addFacetsBuilder(); wsFacet.setProperty(PARAM_ASSIGNEES); facet .forEach((userUuid, count) -> { UserDto user = data.getUserByUuid(userUuid); wsFacet.addValuesBuilder() .setVal(user == null ? "" : user.getLogin()) .setCount(count) .build(); }); wsFacet.build(); }
if (! triedMechs.isEmpty()) { final StringBuilder b = new StringBuilder(); triedMechs.forEach((mechanismName, throwable) -> b.append("\n ").append(mechanismName).append(": ").append(throwable.toString())); triedStr = b.toString(); } else {
private void addProviderParams(OperationGenerator operationGenerator, LinkedHashMap<String, AbstractSerializableParameter<?>> resultParamMap) { resultParamMap.forEach((paramName, param) -> operationGenerator.addProviderParameter(param)); }
private void populateInnerFilters(LinkedHashMap<String, Map<String, String>> wrappedFilterArgs) { List<TokenFilterFactory> innerFilters = new ArrayList<>(); wrappedFilterArgs.forEach((filterName, filterArgs) -> { int idSuffixPos = filterName.indexOf(FILTER_NAME_ID_SEPARATOR); // Format: SPIname[-id] if (idSuffixPos != -1) { // Strip '-id' suffix, if any, prior to SPI lookup filterName = filterName.substring(0, idSuffixPos); } innerFilters.add(TokenFilterFactory.forName(filterName, filterArgs)); }); setInnerFilters(innerFilters); }
@Override public void handle(Exception thrownException, ConsumerRecords<?, ?> data, Consumer<?, ?> consumer, MessageListenerContainer container) { data.partitions() .stream() .collect( Collectors.toMap(tp -> tp, tp -> data.records(tp).get(0).offset(), (u, v) -> (long) v, LinkedHashMap::new)) .forEach(consumer::seek); throw new KafkaException("Seek to current after exception", thrownException); }
/** Call the action for each (variable, expression) defined. * Not called when there is no expression, just a variable. * Not order preserving. */ public void forEachExpr(BiConsumer<Var, Expr> action) { exprs.forEach(action); }
public static LinkedHashMap<String, AnalyzerDefinition> createDefinitionMap( final LinkedHashMap<String, CustomAnalyzer.Factory> factoryMap) { if (factoryMap == null) return null; final LinkedHashMap<String, AnalyzerDefinition> definitionMap = new LinkedHashMap<>(); factoryMap.forEach((name, factory) -> definitionMap.put(name, factory.definition)); return definitionMap; }
void fillAnalyzers(final Map<String, AnalyzerFactory> analyzers) { if (analyzers == null) return; this.localAnalyzerFactoryMap.forEach((name, factory) -> { if (!analyzers.containsKey(name)) analyzers.put(name, factory); }); }
static Map<String, String> getFields(LinkedHashMap<String, FacetDefinition> facets) { if (facets == null || facets.isEmpty()) return null; final Map<String, String> fields = new HashMap<>(); facets.forEach((field, facetDefinition) -> { if (facetDefinition.queries == null) { fields.put(field, facetDefinition.genericFieldName == null ? field : facetDefinition.genericFieldName); } }); return fields; }
void fillFields(final Map<String, FieldDefinition> fields) { if (fields == null) return; this.fieldMap.getFieldDefinitionMap().forEach((name, fieldDef) -> { if (!fields.containsKey(name)) fields.put(name, fieldDef); }); }
/** * Log keys. */ public void logKeys() { internalNodes.forEach((id, node) -> { log.info(String.format("%s : Node[%s]", id, node.getLayer())); }); getLayersById().forEach((id, layer) -> { log.info(String.format("%s : %s", id, layer)); }); }
public LexerNode clone() { LexerNode node = new LexerNode(); node.finalTokenName = this.finalTokenName; this.actions.forEach((key, value) -> node.actions.put(key.clone(), value.clone())); node.ongoingParsing.addAll(this.ongoingParsing); return node; }
protected Object clearUserProfiles(Object value) { if (value instanceof LinkedHashMap<?, ?>) { @SuppressWarnings("unchecked") LinkedHashMap<String, CommonProfile> profiles = (LinkedHashMap<String, CommonProfile>) value; profiles.forEach((name, profile) -> profile.clearSensitiveData()); return profiles; } else { CommonProfile profile = (CommonProfile) value; profile.clearSensitiveData(); return profile; } }