void addContributor(String owner, String repo, String name, int contributions) { Map<String, List<Contributor>> repoContributors = ownerRepoContributors.get(owner); if (repoContributors == null) { repoContributors = new LinkedHashMap<>(); ownerRepoContributors.put(owner, repoContributors); } List<Contributor> contributors = repoContributors.get(repo); if (contributors == null) { contributors = new ArrayList<>(); repoContributors.put(repo, contributors); } contributors.add(new Contributor(name, contributions)); } }
private byte[] encodeHeaderKey(String input, boolean escape) { String inputToUse = (escape ? escape(input) : input); if (this.headerKeyAccessCache.containsKey(inputToUse)) { return this.headerKeyAccessCache.get(inputToUse); } synchronized (this.headerKeyUpdateCache) { byte[] bytes = this.headerKeyUpdateCache.get(inputToUse); if (bytes == null) { bytes = inputToUse.getBytes(StandardCharsets.UTF_8); this.headerKeyAccessCache.put(inputToUse, bytes); this.headerKeyUpdateCache.put(inputToUse, bytes); } return bytes; } }
private void modifyEnvironment(Map<String, String> buildEnv) { for (Map.Entry<String, String> entry : env.entrySet()) { if ("PATH".equals(entry.getKey())) { buildEnv.put("PATH", buildEnv.get("PATH") + File.pathSeparatorChar + env.get("PATH")); } else { buildEnv.put(entry.getKey(), entry.getValue()); } } }
private void innerUpdateEndOffsets(final Map<TopicPartition, Long> newOffsets, final boolean replace) { for (final Map.Entry<TopicPartition, Long> entry : newOffsets.entrySet()) { List<Long> offsets = endOffsets.get(entry.getKey()); if (replace || offsets == null) { offsets = new ArrayList<>(); } offsets.add(entry.getValue()); endOffsets.put(entry.getKey(), offsets); } }
/** * Add an option argument for the given option name and add the given value to the * list of values associated with this option (of which there may be zero or more). * The given value may be {@code null}, indicating that the option was specified * without an associated value (e.g. "--foo" vs. "--foo=bar"). */ public void addOptionArg(String optionName, @Nullable String optionValue) { if (!this.optionArgs.containsKey(optionName)) { this.optionArgs.put(optionName, new ArrayList<>()); } if (optionValue != null) { this.optionArgs.get(optionName).add(optionValue); } }
private void createConnectionsMaxReauthMsMap(Map<String, ?> configs) { for (String mechanism : jaasContexts.keySet()) { String prefix = ListenerName.saslMechanismPrefix(mechanism); Long connectionsMaxReauthMs = (Long) configs.get(prefix + BrokerSecurityConfigs.CONNECTIONS_MAX_REAUTH_MS); if (connectionsMaxReauthMs == null) connectionsMaxReauthMs = (Long) configs.get(BrokerSecurityConfigs.CONNECTIONS_MAX_REAUTH_MS); if (connectionsMaxReauthMs != null) connectionsMaxReauthMsByMechanism.put(mechanism, connectionsMaxReauthMs); } }
@Override public Iterable<Entry<E>> order(List<Entry<E>> insertionOrder) { // We mimic the order from gen. Map<E, Entry<E>> map = new LinkedHashMap<>(); for (Entry<E> entry : insertionOrder) { map.put(entry.getElement(), entry); } Set<E> seen = new HashSet<>(); List<Entry<E>> order = new ArrayList<>(); for (E e : gen.order(new ArrayList<E>(map.keySet()))) { if (seen.add(e)) { order.add(map.get(e)); } } return order; } }
@Override public boolean setInitParameter(String name, String value) { Assert.notNull(name, "Parameter name must not be null"); if (this.initParameters.containsKey(name)) { return false; } this.initParameters.put(name, value); return true; }
private void checkAllDataSources() { Map<String, DataSource> dataSourceMap = selector.getDataSourceMap(); for (Map.Entry<String, DataSource> e : dataSourceMap.entrySet()) { if (!(e.getValue() instanceof DruidDataSource)) { continue; } boolean flag = check(e.getKey(), (DruidDataSource) e.getValue()); if (flag) { errorCounts.put(e.getKey(), 0); } else { if (!errorCounts.containsKey(e.getKey())) { errorCounts.put(e.getKey(), 0); } int count = errorCounts.get(e.getKey()); errorCounts.put(e.getKey(), count + 1); } } }
private void updateBindingContext(BindingContext context, ServerWebExchange exchange) { Map<String, Object> model = context.getModel().asMap(); model.keySet().stream() .filter(name -> isBindingCandidate(name, model.get(name))) .filter(name -> !model.containsKey(BindingResult.MODEL_KEY_PREFIX + name)) .forEach(name -> { WebExchangeDataBinder binder = context.createDataBinder(exchange, model.get(name), name); model.put(BindingResult.MODEL_KEY_PREFIX + name, binder.getBindingResult()); }); }
@SuppressWarnings("unchecked") public void addAfterComment(String comment) { if (attributes == null) { attributes = new HashMap<String, Object>(1); } List<String> comments = (List<String>) attributes.get("format.after_comment"); if (comments == null) { comments = new ArrayList<String>(2); attributes.put("format.after_comment", comments); } comments.add(comment); }
void putSanitizeName(RType rType, String sanitizeName, String rawName) { HashMap<String, String> sanitizeNameMap; if (!sanitizeTypeMap.containsKey(rType)) { sanitizeNameMap = new HashMap<>(); sanitizeTypeMap.put(rType, sanitizeNameMap); } else { sanitizeNameMap = sanitizeTypeMap.get(rType); } if (!sanitizeNameMap.containsKey(sanitizeName)) { sanitizeNameMap.put(sanitizeName, rawName); } }
@Override public BenchmarkResultHook addResults(Map<String, Long> results) { requireNonNull(results, "results is null"); for (Entry<String, Long> entry : results.entrySet()) { Long currentSum = resultsSum.get(entry.getKey()); if (currentSum == null) { currentSum = 0L; } resultsSum.put(entry.getKey(), currentSum + entry.getValue()); } resultsCount++; return this; }