本文整理了Java中java.util.Map.putAll()
方法的一些代码示例,展示了Map.putAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Map.putAll()
方法的具体详情如下:
包路径:java.util.Map
类名称:Map
方法名:putAll
[英]Copies every mapping in the specified Map to this Map.
[中]将指定映射中的每个映射复制到此映射。
代码示例来源:origin: google/guava
@Override
public void putAll(Map<? extends K, ? extends V> map) {
for (Entry<? extends K, ? extends V> entry : map.entrySet()) {
checkArgument(apply(entry.getKey(), entry.getValue()));
}
unfiltered.putAll(map);
}
代码示例来源:origin: google/guava
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);
}
代码示例来源:origin: google/j2objc
@Override
public void putAll(Map<? extends K, ? extends V> map) {
for (Entry<? extends K, ? extends V> entry : map.entrySet()) {
checkArgument(apply(entry.getKey(), entry.getValue()));
}
unfiltered.putAll(map);
}
代码示例来源:origin: stanfordnlp/CoreNLP
public TwoDimensionalMap(TwoDimensionalMap<K1, K2, V> tdm) {
this(tdm.mf1, tdm.mf2);
for (K1 k1 : tdm.map.keySet()) {
Map<K2, V> m = tdm.map.get(k1);
Map<K2, V> copy = mf2.newMap();
copy.putAll(m);
this.map.put(k1, copy);
}
}
代码示例来源:origin: spring-projects/spring-framework
@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);
}
}
代码示例来源:origin: apache/storm
/**
* same as clojure's (merge-with merge m1 m2).
*/
private static Map mergeMaps(Map m1, Map m2) {
if (m2 == null) {
return m1;
}
for (Object o : m2.entrySet()) {
Map.Entry entry = (Map.Entry) o;
Object k = entry.getKey();
Map existing = (Map) m1.get(k);
if (existing == null) {
m1.put(k, entry.getValue());
} else {
existing.putAll((Map) m2.get(k));
}
}
return m1;
}
代码示例来源:origin: ctripcorp/apollo
/**
* 合并用户对namespace的修改
*/
private Map<String, String> mergeOverriddenProperties(String namespace, Map<String, String> configurations) {
if (addedOrModifiedPropertiesOfNamespace.containsKey(namespace)) {
configurations.putAll(addedOrModifiedPropertiesOfNamespace.get(namespace));
}
if (deletedKeysOfNamespace.containsKey(namespace)) {
for (String k : deletedKeysOfNamespace.get(namespace)) {
configurations.remove(k);
}
}
return configurations;
}
代码示例来源:origin: stanfordnlp/CoreNLP
public void updatePatterns(Map<String, Map<Integer, Set<E>>> tempPatsForSents) {
for(Map.Entry<String, Map<Integer, Set<E>>> en :tempPatsForSents.entrySet()){
Map<Integer, Set<E>> m = getPatternsForAllTokens(en.getKey());
if(m == null)
m = new HashMap<>();
tempPatsForSents.get(en.getKey()).putAll(m);
}
this.addPatterns(tempPatsForSents);
close();
}
代码示例来源:origin: apache/usergrid
public <T> void mergeDataset( String property, Map<String, T> new_metadata ) {
Object md = dynamic_properties.get( property );
if ( !( md instanceof Map<?, ?> ) ) {
md = new HashMap<String, T>();
dynamic_properties.put( property, md );
}
@SuppressWarnings("unchecked") Map<String, T> metadata = ( Map<String, T> ) md;
metadata.putAll( new_metadata );
}
代码示例来源:origin: stanfordnlp/CoreNLP
public ConstantsAndVariables(Properties props, Map<String, Set<CandidatePhrase>> labelDictionary, Map<String, Class<? extends Key<String>>> answerClass, Map<String, Class> generalizeClasses,
Map<String, Map<Class, Object>> ignoreClasses) throws IOException {
//make the list unmodifiable!
for(Entry<String, Set<CandidatePhrase>> en2: labelDictionary.entrySet()){
seedLabelDictionary.put(en2.getKey(), Collections.unmodifiableSet(en2.getValue()));
}
this.labels = labelDictionary.keySet();
this.answerClass = answerClass;
this.generalizeClasses = generalizeClasses;
if(this.generalizeClasses == null)
this.generalizeClasses = new HashMap<>();
this.generalizeClasses.putAll(answerClass);
this.ignoreWordswithClassesDuringSelection = ignoreClasses;
setUp(props);
}
代码示例来源:origin: eirslett/frontend-maven-plugin
private Map<String, String> createEnvironment(List<String> paths, Platform platform, Map<String, String> additionalEnvironment) {
final Map<String, String> environment = new HashMap<>(System.getenv());
String pathVarName = "PATH";
String pathVarValue = environment.get(pathVarName);
if (platform.isWindows()) {
for (Map.Entry<String, String> entry : environment.entrySet()) {
if ("PATH".equalsIgnoreCase(entry.getKey())) {
pathVarName = entry.getKey();
pathVarValue = entry.getValue();
}
}
}
StringBuilder pathBuilder = new StringBuilder();
if (pathVarValue != null) {
pathBuilder.append(pathVarValue).append(File.pathSeparator);
}
for (String path : paths) {
pathBuilder.insert(0, File.pathSeparator).insert(0, path);
}
environment.put(pathVarName, pathBuilder.toString());
if (additionalEnvironment != null) {
environment.putAll(additionalEnvironment);
}
return environment;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Merge a single hint into a map of hints, possibly creating and copying
* all hints into a new map, or otherwise if the map of hints is empty,
* creating a new single entry map.
* @param hints a map of hints to be merge
* @param hintName the hint name to merge
* @param hintValue the hint value to merge
* @return a single map with all hints
*/
public static Map<String, Object> merge(Map<String, Object> hints, String hintName, Object hintValue) {
if (hints.isEmpty()) {
return Collections.singletonMap(hintName, hintValue);
}
else {
Map<String, Object> result = new HashMap<>(hints.size() + 1);
result.putAll(hints);
result.put(hintName, hintValue);
return result;
}
}
代码示例来源:origin: apache/storm
/**
* Invoked once immediately after construction
*
* @param storm_conf Storm configuration
*/
@Override
public void prepare(Map<String, Object> storm_conf) {
Map<?, ?> params = (Map<?, ?>) storm_conf.get(Config.STORM_GROUP_MAPPING_SERVICE_PARAMS);
Map<String, Set<String>> mapping = (Map<String, Set<String>>) params.get(STORM_FIXED_GROUP_MAPPING);
if (mapping != null) {
cachedGroups.putAll(mapping);
} else {
LOG.warn("There is no initial group mapping");
}
}
代码示例来源:origin: apache/incubator-dubbo
for (Map.Entry<String, String> entry : parameters.entrySet()) {
String value = getParameters().get(entry.getKey());
if (value == null) {
if (entry.getValue() != null) {
hasAndEqual = false;
break;
if (!value.equals(entry.getValue())) {
hasAndEqual = false;
break;
map.putAll(parameters);
return new URL(protocol, username, password, host, port, path, map);
代码示例来源:origin: google/guava
static <T extends StandardTable<Object, Object, Object>> T populate(
SerializationStreamReader reader, T table) throws SerializationException {
Map<?, ?> hashMap = (Map<?, ?>) reader.readObject();
for (Entry<?, ?> row : hashMap.entrySet()) {
table.row(row.getKey()).putAll((Map<?, ?>) row.getValue());
}
return table;
}
代码示例来源:origin: apache/zookeeper
@Override
public Map<String, Object> values() {
Map<String, Object> m = new LinkedHashMap<>();
for (Map.Entry<String, AvgMinMaxCounter> entry : counters.entrySet()) {
m.putAll(entry.getValue().values());
}
return m;
}
}
代码示例来源:origin: alibaba/jstorm
public Topologies(Map<String, TopologyDetails> topologies) {
if (topologies == null)
topologies = new HashMap<>();
this.topologies = new HashMap<>(topologies.size());
this.topologies.putAll(topologies);
this.nameToId = new HashMap<>(topologies.size());
for (String topologyId : topologies.keySet()) {
TopologyDetails topology = topologies.get(topologyId);
this.nameToId.put(topology.getName(), topologyId);
}
}
代码示例来源:origin: SonarSource/sonarqube
private void loadInstances() {
pluginInstancesByKeys.putAll(loader.load(pluginInfosByKeys));
for (Map.Entry<String, Plugin> e : pluginInstancesByKeys.entrySet()) {
keysByClassLoader.put(e.getValue().getClass().getClassLoader(), e.getKey());
}
}
代码示例来源:origin: SonarSource/sonarqube
/**
* Only keep props that are not in parent
*/
private Map<String, String> collectModuleSpecificProps(DefaultInputModule module) {
Map<String, String> moduleSpecificProps = new HashMap<>();
AbstractProjectOrModule parent = hierarchy.parent(module);
if (parent == null) {
moduleSpecificProps.putAll(module.properties());
} else {
Map<String, String> parentProps = parent.properties();
for (Map.Entry<String, String> entry : module.properties().entrySet()) {
if (!parentProps.containsKey(entry.getKey()) || !parentProps.get(entry.getKey()).equals(entry.getValue())) {
moduleSpecificProps.put(entry.getKey(), entry.getValue());
}
}
}
return moduleSpecificProps;
}
代码示例来源:origin: apache/incubator-druid
private Map<String, Object> contextWithSqlId(Map<String, Object> queryContext)
{
Map<String, Object> newContext = new HashMap<>();
if (queryContext != null) {
newContext.putAll(queryContext);
}
if (!newContext.containsKey(PlannerContext.CTX_SQL_QUERY_ID)) {
newContext.put(PlannerContext.CTX_SQL_QUERY_ID, UUID.randomUUID().toString());
}
return newContext;
}
内容来源于网络,如有侵权,请联系作者删除!