private static Map<String, String> addCharsetParameter(Charset charset, Map<String, String> parameters) { Map<String, String> map = new LinkedHashMap<>(parameters); map.put(PARAM_CHARSET, charset.name()); return map; }
public Challenge(String scheme, Map<String, String> authParams) { if (scheme == null) throw new NullPointerException("scheme == null"); if (authParams == null) throw new NullPointerException("authParams == null"); this.scheme = scheme; Map<String, String> newAuthParams = new LinkedHashMap<>(); for (Entry<String, String> authParam : authParams.entrySet()) { String key = (authParam.getKey() == null) ? null : authParam.getKey().toLowerCase(US); newAuthParams.put(key, authParam.getValue()); } this.authParams = unmodifiableMap(newAuthParams); }
public BasicCertificateChainCleaner(X509Certificate... caCerts) { subjectToCaCerts = new LinkedHashMap<>(); for (X509Certificate caCert : caCerts) { X500Principal subject = caCert.getSubjectX500Principal(); Set<X509Certificate> subjectCaCerts = subjectToCaCerts.get(subject); if (subjectCaCerts == null) { subjectCaCerts = new LinkedHashSet<>(1); subjectToCaCerts.put(subject, subjectCaCerts); } subjectCaCerts.add(caCert); } }
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)); } }
public static Map<TimeUnit,Long> computeDiff(Date date1, Date date2) { long diffInMillies = date2.getTime() - date1.getTime(); List<TimeUnit> units = new ArrayList<TimeUnit>(EnumSet.allOf(TimeUnit.class)); Collections.reverse(units); Map<TimeUnit,Long> result = new LinkedHashMap<TimeUnit,Long>(); long milliesRest = diffInMillies; for ( TimeUnit unit : units ) { long diff = unit.convert(milliesRest,TimeUnit.MILLISECONDS); long diffInMilliesForUnit = unit.toMillis(diff); milliesRest = milliesRest - diffInMilliesForUnit; result.put(unit,diff); } return result; }
public Map<String, List<String>> getTableToColumnAccessMap() { // Must be deterministic order map for consistent q-test output across Java versions Map<String, List<String>> mapping = new LinkedHashMap<String, List<String>>(); for (Map.Entry<String, Set<String>> entry : tableToColumnAccessMap.entrySet()) { List<String> sortedCols = new ArrayList<String>(entry.getValue()); Collections.sort(sortedCols); mapping.put(entry.getKey(), sortedCols); } return mapping; }
public Arguments() { namedArgs = new LinkedHashMap<>(); positionalArgs = new ArrayList<>(); }
/** * {@inheritDoc} */ public Map<TypeDescription, Class<?>> inject(Map<? extends TypeDescription, byte[]> types) { Map<String, byte[]> binaryRepresentations = new LinkedHashMap<String, byte[]>(); for (Map.Entry<? extends TypeDescription, byte[]> entry : types.entrySet()) { binaryRepresentations.put(entry.getKey().getName(), entry.getValue()); } Map<String, Class<?>> loadedTypes = injectRaw(binaryRepresentations); Map<TypeDescription, Class<?>> result = new LinkedHashMap<TypeDescription, Class<?>>(); for (TypeDescription typeDescription : types.keySet()) { result.put(typeDescription, loadedTypes.get(typeDescription.getName())); } return result; } }
private void update(Map<TopicPartition, S> partitionToState) { LinkedHashMap<String, List<TopicPartition>> topicToPartitions = new LinkedHashMap<>(); for (TopicPartition tp : partitionToState.keySet()) { List<TopicPartition> partitions = topicToPartitions.computeIfAbsent(tp.topic(), k -> new ArrayList<>()); partitions.add(tp); } for (Map.Entry<String, List<TopicPartition>> entry : topicToPartitions.entrySet()) { for (TopicPartition tp : entry.getValue()) { S state = partitionToState.get(tp); map.put(tp, state); } } }
Map<String,String> map=new LinkedHashMap<>(); map.put("Active","33"); map.put("Renewals Completed","3"); map.put("Application","15"); Map.Entry<String,String> entry=map.entrySet().iterator().next(); String key= entry.getKey(); String value=entry.getValue(); System.out.println(key); System.out.println(value);
@SuppressWarnings({"unchecked", "rawtypes"}) protected void visitMap(Map<?, ?> mapVal) { Map newContent = new LinkedHashMap(); boolean entriesModified = false; for (Map.Entry entry : mapVal.entrySet()) { Object key = entry.getKey(); int keyHash = (key != null ? key.hashCode() : 0); Object newKey = resolveValue(key); int newKeyHash = (newKey != null ? newKey.hashCode() : 0); Object val = entry.getValue(); Object newVal = resolveValue(val); newContent.put(newKey, newVal); entriesModified = entriesModified || (newVal != val || newKey != key || newKeyHash != keyHash); } if (entriesModified) { mapVal.clear(); mapVal.putAll(newContent); } }
public void run() throws Exception { Map<String, String> requestBody = new LinkedHashMap<>(); requestBody.put("longUrl", "https://publicobject.com/2014/12/04/html-formatting-javadocs/"); RequestBody jsonRequestBody = RequestBody.create( MEDIA_TYPE_JSON, mapJsonAdapter.toJson(requestBody)); Request request = new Request.Builder() .url("https://www.googleapis.com/urlshortener/v1/url?key=" + GOOGLE_API_KEY) .post(jsonRequestBody) .build(); try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); System.out.println(response.body().string()); } }
public Collection<Set<T>> getEquivalentClasses() { // map from root element to all element in the tree Map<T, Set<T>> rootToTreeElements = new LinkedHashMap<>(); for (Map.Entry<T, Entry<T>> entry : map.entrySet()) { T node = entry.getKey(); T root = findInternal(node); rootToTreeElements.computeIfAbsent(root, unused -> new LinkedHashSet<>()); rootToTreeElements.get(root).add(node); } return rootToTreeElements.values(); } }
private void putAll(Iterable<Entry<K, V>> entries) { Map<K, V> map = new LinkedHashMap<>(); for (Entry<K, V> entry : entries) { map.put(entry.getKey(), entry.getValue()); } getMap().putAll(map); }
private Map<String, Map<String, Exclusion>> unmodifiableRefStringMap( Map<String, Map<String, ParamsBuilder>> mapmap) { LinkedHashMap<String, Map<String, Exclusion>> fieldNameByClassName = new LinkedHashMap<>(); for (Map.Entry<String, Map<String, ParamsBuilder>> entry : mapmap.entrySet()) { fieldNameByClassName.put(entry.getKey(), unmodifiableRefMap(entry.getValue())); } return unmodifiableMap(fieldNameByClassName); }
/** @return a copy of the internal {@link Map} that maps {@link MediaItem}s to their children. */ public Map<MediaItem, List<MediaItem>> getCopyOfMediaItemChildren() { final Map<MediaItem, List<MediaItem>> copyOfMediaItemChildren = new LinkedHashMap<>(); for (MediaItem parent : mediaItemChildren.keySet()) { List<MediaItem> children = new ArrayList<>(mediaItemChildren.get(parent)); copyOfMediaItemChildren.put(parent, children); } return copyOfMediaItemChildren; } }
public void addMethodBinding(ListenerClass listener, ListenerMethod method, MethodViewBinding binding) { Map<ListenerMethod, Set<MethodViewBinding>> methods = methodBindings.get(listener); Set<MethodViewBinding> set = null; if (methods == null) { methods = new LinkedHashMap<>(); methodBindings.put(listener, methods); } else { set = methods.get(method); } if (set == null) { set = new LinkedHashSet<>(); methods.put(method, set); } set.add(binding); }
private Map<String, Exclusion> unmodifiableRefMap(Map<String, ParamsBuilder> fieldBuilderMap) { Map<String, Exclusion> fieldMap = new LinkedHashMap<>(); for (Map.Entry<String, ParamsBuilder> fieldEntry : fieldBuilderMap.entrySet()) { fieldMap.put(fieldEntry.getKey(), new Exclusion(fieldEntry.getValue())); } return unmodifiableMap(fieldMap); }
private Map configAsJson(Iterable<StageConfigurationModel> stages) { List jsonList = new ArrayList(); for (StageConfigurationModel stageInfo : stages) { Map<String, Object> jsonMap = new LinkedHashMap<>(); jsonMap.put("name", stageInfo.getName()); jsonMap.put("isAutoApproved", valueOf(stageInfo.isAutoApproved())); jsonList.add(jsonMap); } Map<String, Object> jsonMap = new LinkedHashMap<>(); jsonMap.put("stages", jsonList); return jsonMap; }
private static Map<ByteString, Integer> nameToFirstIndex() { Map<ByteString, Integer> result = new LinkedHashMap<>(STATIC_HEADER_TABLE.length); for (int i = 0; i < STATIC_HEADER_TABLE.length; i++) { if (!result.containsKey(STATIC_HEADER_TABLE[i].name)) { result.put(STATIC_HEADER_TABLE[i].name, i); } } return Collections.unmodifiableMap(result); }