本文整理匯總了Java中java.util.Map.putAll方法的典型用法代碼示例。如果您正苦於以下問題:Java Map.putAll方法的具體用法?Java Map.putAll怎麽用?Java Map.putAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.Map
的用法示例。
在下文中一共展示了Map.putAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDataGenerators
import java.util.Map; //導入方法依賴的package包/類
/**
* Get all data generators applicable to a given path and scope.
*
* @param paths the audit paths
* @return Returns all data generators mapped to their key-path
*/
public Map<String, DataGenerator> getDataGenerators(Set<String> paths)
{
Map<String, DataGenerator> amalgamatedGenerators = new HashMap<String, DataGenerator>(13);
for (String path : paths)
{
Map<String, DataGenerator> generators = dataGenerators.get(path);
if (generators != null)
{
// Copy values to combined map
amalgamatedGenerators.putAll(generators);
}
}
// Done
if (logger.isDebugEnabled())
{
logger.debug(
"Looked up data generators: \n" +
" Paths: " + paths + "\n" +
" Found: " + amalgamatedGenerators);
}
return amalgamatedGenerators;
}
示例2: configure
import java.util.Map; //導入方法依賴的package包/類
@Override
public void configure(Map<String, ?> configs, boolean isKey) {
Map<String, Object> serializerConfigs = new HashMap<>();
serializerConfigs.putAll(configs);
Map<String, Object> deserializerConfigs = new HashMap<>();
deserializerConfigs.putAll(configs);
Object encodingValue = configs.get("converter.encoding");
if (encodingValue != null) {
serializerConfigs.put("serializer.encoding", encodingValue);
deserializerConfigs.put("deserializer.encoding", encodingValue);
}
serializer.configure(serializerConfigs, isKey);
deserializer.configure(deserializerConfigs, isKey);
}
示例3: buildProperties
import java.util.Map; //導入方法依賴的package包/類
private Map<String, Property> buildProperties(Model model, Map<String, Property> properties) {
if (model != null) {
//some times model can be composed,Composed means if a class inherits another class or interface.
if (model instanceof ComposedModel) {
List<Model> allModels = ((ComposedModel) model).getAllOf();
for (Model eachModel : allModels) {
properties.putAll(buildProperties(eachModel, properties));
}
} else if (model instanceof RefModel) {
buildProperties(definitions.get(((RefModel) model).getSimpleRef()), properties);
} else {
// in other models such as array,modelImpl,abstract getting properties are straight forward.
if (model.getProperties() != null) {
properties.putAll(model.getProperties());
}
}
}
return properties;
}
示例4: loadConfigurationProperties
import java.util.Map; //導入方法依賴的package包/類
private Map<String, String> loadConfigurationProperties(
final String configurationPropertiesPathname, Map<String, String> configurationProperties) {
configurationProperties =
(configurationProperties != null ? configurationProperties : new HashMap<String, String>());
if (IOUtils.isExistingPathname(configurationPropertiesPathname)) {
try {
configurationProperties.putAll(ShellCommands
.loadPropertiesFromURL(new File(configurationPropertiesPathname).toURI().toURL()));
} catch (MalformedURLException ignore) {
LogWrapper.getInstance()
.warning(String.format(
"Failed to load GemFire configuration properties from pathname (%1$s)!",
configurationPropertiesPathname), ignore);
}
}
return configurationProperties;
}
示例5: runJavaFix
import java.util.Map; //導入方法依賴的package包/類
private ModificationResult runJavaFix(final JavaFix jf) throws IOException {
FileObject file = Accessor.INSTANCE.getFile(jf);
JavaSource js = JavaSource.forFileObject(file);
final Map<FileObject, List<Difference>> changes = new HashMap<FileObject, List<Difference>>();
ModificationResult mr = js.runModificationTask(new Task<WorkingCopy>() {
public void run(WorkingCopy wc) throws Exception {
if (wc.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) {
return;
}
Map<FileObject, byte[]> resourceContentChanges = new HashMap<FileObject, byte[]>();
Accessor.INSTANCE.process(jf, wc, true, resourceContentChanges, /*Ignored for now:*/new ArrayList<RefactoringElementImplementation>());
BatchUtilities.addResourceContentChanges(resourceContentChanges, changes);
}
});
changes.putAll(JavaSourceAccessor.getINSTANCE().getDiffsFromModificationResult(mr));
return JavaSourceAccessor.getINSTANCE().createModificationResult(changes, Collections.<Object, int[]>emptyMap());
}
示例6: generateNameToHash
import java.util.Map; //導入方法依賴的package包/類
/**
* Generates a map of module name to hash value.
*/
static Map<String, byte[]> generateNameToHash(ModuleHashes[] recordedHashes) {
Map<String, byte[]> nameToHash = null;
boolean secondSeen = false;
// record the hashes to build HashSupplier
for (ModuleHashes mh : recordedHashes) {
if (mh != null) {
// if only one module contain ModuleHashes, use it
if (nameToHash == null) {
nameToHash = mh.hashes();
} else {
if (!secondSeen) {
nameToHash = new HashMap<>(nameToHash);
secondSeen = true;
}
nameToHash.putAll(mh.hashes());
}
}
}
return (nameToHash != null) ? nameToHash : Collections.emptyMap();
}
示例7: getParaObjectFromSource
import java.util.Map; //導入方法依賴的package包/類
/**
* Converts the source of an ES document to {@link ParaObject}.
* @param <P> object type
* @param source a map of keys and values coming from ES
* @return a new ParaObject
*/
static <P extends ParaObject> P getParaObjectFromSource(Map<String, Object> source) {
if (source == null) {
return null;
}
Map<String, Object> data = new HashMap<>(source.size());
data.putAll(source);
// retrieve the JSON for the original properties field and deserialize it
if (nestedMode() && data.containsKey(PROPS_JSON)) {
try {
Map<String, Object> props = ParaObjectUtils.getJsonReader(Map.class).
readValue((String) data.get(PROPS_JSON));
data.put(PROPS_FIELD, props);
} catch (Exception e) {
logger.error(null, e);
}
data.remove(PROPS_JSON);
}
data.remove("_docid");
return ParaObjectUtils.setAnnotatedFields(data);
}
示例8: getCustomTypes
import java.util.Map; //導入方法依賴的package包/類
/**
* Use grep to see all the files that contain TypeSerializer, and collect them all
*/
private static Map<String, String> getCustomTypes() throws IOException {
String line;
Map<String, String> types = new HashMap<>();
ProcessBuilder builder = new ProcessBuilder("grep", "-rlP", "extends\\s+TypeSerializer");
builder.redirectErrorStream(true);
Process p = builder.start();
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
// This grep command will output only the file names of the files that contain a TypeSerializer
while (true) {
line = r.readLine();
if (line == null) {
break;
}
// Add all the custom types contained in that file
types.putAll(getCustomTypes(line));
}
return types;
}
示例9: addDeserializerToConfig
import java.util.Map; //導入方法依賴的package包/類
public static Map<String, Object> addDeserializerToConfig(Map<String, Object> configs,
Deserializer<?> keyDeserializer,
Deserializer<?> valueDeserializer) {
Map<String, Object> newConfigs = new HashMap<String, Object>();
newConfigs.putAll(configs);
if (keyDeserializer != null)
newConfigs.put(KEY_DESERIALIZER_CLASS_CONFIG, keyDeserializer.getClass());
if (valueDeserializer != null)
newConfigs.put(VALUE_DESERIALIZER_CLASS_CONFIG, valueDeserializer.getClass());
return newConfigs;
}
示例10: getStringStringMap
import java.util.Map; //導入方法依賴的package包/類
private Map<String, String> getStringStringMap(String index) {
Jedis jedis = getJedis();
MapStructure<String> mapStructure = RedisStrutureBuilder.ofMap(jedis, String.class).withNameSpace(nameSpace).build();
Map<String, String> map = mapStructure.get(index);
Map<String, String> result = new HashMap<>();
result.putAll(map);
if (jedis != null) {
jedis.close();
}
return result;
}
示例11: getFlows
import java.util.Map; //導入方法依賴的package包/類
@Get("json")
@SuppressWarnings("unchecked")
public Map<String, Object> getFlows() {
Map<String, Object> response = new HashMap<>();
String switchId = (String) this.getRequestAttributes().get("switch_id");
logger.debug("Get flows for switch: {}", switchId);
ISwitchManager switchManager = (ISwitchManager) getContext().getAttributes()
.get(ISwitchManager.class.getCanonicalName());
try {
OFFlowStatsReply replay = switchManager.dumpFlowTable(DatapathId.of(switchId));
logger.debug("OF_STATS: {}", replay);
if (replay != null) {
for (OFFlowStatsEntry entry : replay.getEntries()) {
String key = String.format("flow-0x%s",
Long.toHexString(entry.getCookie().getValue()).toUpperCase());
response.put(key, buildFlowStat(entry));
}
}
} catch (IllegalArgumentException exception) {
String messageString = "No such switch";
logger.error("{}: {}", messageString, switchId, exception);
MessageError responseMessage = new MessageError(DEFAULT_CORRELATION_ID, System.currentTimeMillis(),
ErrorType.PARAMETERS_INVALID.toString(), messageString, exception.getMessage());
response.putAll(MAPPER.convertValue(responseMessage, Map.class));
}
return response;
}
示例12: execute
import java.util.Map; //導入方法依賴的package包/類
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
checkConfiguration();
MetricFilterPublisher publisher =
dryRun ? new DryRunMetricFilterPublisher(getLog()) :
new GenerateMetricFilterPublisher(getLog(),
new File(project.getBuild().getDirectory()));
// Gets a map of fully-namespaced metric names -> annotated fields in classes that extend LambdaMetricSet
Map<String, Field> metricFields = new HashMap<>();
try {
metricFields.putAll(new MetricsFinder(project).find());
} catch (DependencyResolutionRequiredException | MalformedURLException e) {
throw new MojoExecutionException("Could not scan classpath for metric fields", e);
}
if (!metricFields.isEmpty()) {
getLog().info(String.format("Found [%d] metric fields in classpath.", metricFields.size()));
List<MetricFilter> metricFilters = getMetricFilters(metricFields);
getLog().info(String.format("Published [%d] metric filters.",
publisher.publishMetricFilters(metricFilters)));
} else {
getLog().warn("Did not find any metric fields in classpath.");
}
}
示例13: getAvailableOperations
import java.util.Map; //導入方法依賴的package包/類
@Test
public void getAvailableOperations() {
// when
Map<String, String> operations = new HashMap<String, String>();
operations.putAll(AuditLogOperationGroups.getInstance()
.getAvailableOperations());
// then
assertAvailableOperations(operations);
}
示例14: appendJdbcTypeMappingQuery
import java.util.Map; //導入方法依賴的package包/類
static final void appendJdbcTypeMappingQuery(StringBuilder buf, String mysqlTypeColumnName) {
buf.append("CASE ");
Map<String, Integer> typesMap = new HashMap<String, Integer>();
typesMap.putAll(mysqlToJdbcTypesMap);
typesMap.put("BINARY", Integer.valueOf(Types.BINARY));
typesMap.put("VARBINARY", Integer.valueOf(Types.VARBINARY));
Iterator<String> mysqlTypes = typesMap.keySet().iterator();
while (mysqlTypes.hasNext()) {
String mysqlTypeName = mysqlTypes.next();
buf.append(" WHEN ");
buf.append(mysqlTypeColumnName);
buf.append("='");
buf.append(mysqlTypeName);
buf.append("' THEN ");
buf.append(typesMap.get(mysqlTypeName));
if (mysqlTypeName.equalsIgnoreCase("DOUBLE") || mysqlTypeName.equalsIgnoreCase("FLOAT") || mysqlTypeName.equalsIgnoreCase("DECIMAL")
|| mysqlTypeName.equalsIgnoreCase("NUMERIC")) {
buf.append(" WHEN ");
buf.append(mysqlTypeColumnName);
buf.append("='");
buf.append(mysqlTypeName);
buf.append(" unsigned' THEN ");
buf.append(typesMap.get(mysqlTypeName));
}
}
buf.append(" ELSE ");
buf.append(Types.OTHER);
buf.append(" END ");
}
示例15: deserialize
import java.util.Map; //導入方法依賴的package包/類
@Override
public Station deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
Station station = new Station();
JsonObject obj = jsonElement.getAsJsonObject();
Type songCollectionListType = new TypeToken<List<SongCollection>>(){}.getType();
Type scheduleEntryListType = new TypeToken<List<ScheduleEntry>>(){}.getType();
Type namedContextConditionsType = new TypeToken<Map<String, ContextCondition>>(){}.getType();
Type contextListType = new TypeToken<List<ContextEntry>>(){}.getType();
final Map<String, ContextCondition> namedContextConditions = new HashMap<>();
station.setName(obj.get("name").getAsString());
if(obj.has("description"))
station.setDescription(obj.get("description").getAsString());
if(obj.has("thumbnail"))
station.setThumbnail(obj.get("thumbnail").getAsString());
if(obj.has("collections")){
List<SongCollection> coll = jsonDeserializationContext.deserialize(obj.get("collections"), songCollectionListType);
coll.stream().forEach(x -> station.addCollection(x));
}
if(obj.has("schedule"))
station.setSchedule(jsonDeserializationContext.deserialize(obj.get("schedule"), scheduleEntryListType));
if(obj.has("filters"))
namedContextConditions.putAll(jsonDeserializationContext.deserialize(obj.get("filters"), namedContextConditionsType));
if(obj.has("contexts"))
station.setContexts(jsonDeserializationContext.deserialize(obj.get("contexts"), contextListType));
for(ContextEntry cont : station.getContexts()) {
namedContextConditions.putAll(cont.getConditions().getInlinedContextConditions());
}
namedContextConditions.keySet().stream().forEach(x -> station.addFilter(x, namedContextConditions.get(x)));
// Set all necessary parent references
station.getFilters().values().stream().forEach(x -> x.setStation(station));
station.getSchedule().stream().forEach(x -> x.setStation(station));
station.getContexts().stream().forEach(x -> {
x.setStation(station);
x.getConditions().setContext(x);
x.getConditions().getConjunctions().stream().forEach(y -> y.setFormula(x.getConditions()));
});
station.getCollections().values().stream().forEach(x -> x.setStation(station));
return station;
}