List of usage examples for java.util Map forEach
default void forEach(BiConsumer<? super K, ? super V> action)
From source file:org.apache.rocketmq.serializer.avro.AvroUtils.java
public static GenericRecord newGenericRecordFromMap(Schema schema, Map<String, Object> map) { Validate.notNull(schema);//from ww w. j a v a 2s . co m Validate.notNull(map); GenericRecord record = new GenericData.Record(schema); map.forEach((k, v) -> { record.put(k, v); }); return record; }
From source file:org.trustedanalytics.hadoop.admin.tools.HadoopClientParamsImporter.java
static String returnJSON(Map<String, String> props) { ObjectMapper objectMapper = new ObjectMapper(); JsonNode rootNode = objectMapper.createObjectNode(); props.forEach((k, v) -> ((ObjectNode) rootNode).with(ConfigConstants.HADOOP_CONFIG_KEY_VALUE).put(k, v)); return escapeCharacters(rootNode.toString()); }
From source file:org.pentaho.platform.dataaccess.datasource.wizard.service.impl.DatasourceResource.java
static String prepareDataSourceInfo(String dataSourceInfo) { StringBuilder sb = new StringBuilder(); Map<String, String> parameters = DataSourceInfoUtil.parseDataSourceInfo(dataSourceInfo); parameters.forEach((key, value) -> { String unescapedValue = StringEscapeUtils.unescapeXml(value); String valueWithEscapedQuotes = DataSourceInfoUtil.escapeQuotes(unescapedValue); sb.append(key);//from w w w . jav a 2s . co m sb.append("=\""); sb.append(valueWithEscapedQuotes); sb.append("\""); sb.append(";"); }); return sb.toString(); }
From source file:org.apache.flink.table.client.config.Deployment.java
/** * Creates a new deployment enriched with additional properties. *///from w w w. ja va 2s.c o m public static Deployment enrich(Deployment deploy, Map<String, String> properties) { final Map<String, String> newProperties = new HashMap<>(deploy.properties); properties.forEach((k, v) -> { final String normalizedKey = k.toLowerCase(); if (k.startsWith(PropertyStrings.DEPLOYMENT + ".")) { newProperties.put(normalizedKey.substring(PropertyStrings.DEPLOYMENT.length() + 1), v); } }); return new Deployment(newProperties); }
From source file:org.apache.james.queue.rabbitmq.view.cassandra.EnqueuedMailsDaoUtil.java
private static PerRecipientHeaders fromHeaderMap(Map<String, UDTValue> rawMap) { PerRecipientHeaders result = new PerRecipientHeaders(); rawMap.forEach((key, value) -> result.addHeaderForRecipient(PerRecipientHeaders.Header.builder() .name(value.getString(HEADER_NAME)).value(value.getString(HEADER_VALUE)).build(), toMailAddress(key))); return result; }
From source file:com.capitaltg.bbcodeguard.StringUtils.java
public static String replaceAll(String original, Map<String, String> replacements) { if (original == null || replacements == null || replacements.isEmpty()) { return original; }/* w w w . ja v a 2 s.co m*/ StringHolder response = new StringHolder(original); replacements.forEach((n, v) -> response.replaceAll("@" + n + "@", v)); return response.toString(); }
From source file:org.ballerinalang.config.ConfigProcessor.java
private static BConfig parseRuntimeParams(Map<String, String> runtimeParams) { StringBuilder stringBuilder = new StringBuilder(); runtimeParams.forEach((key, val) -> stringBuilder.append(key).append('=') // TODO: need to handle this in a better way .append('\"').append(StringEscapeUtils.escapeJava(val)).append('\"').append('\n')); ANTLRInputStream runtimeConfigsStream = new ANTLRInputStream(stringBuilder.toString()); BConfig runtimeConfigEntries = new BConfig(); ParseTreeWalker treeWalker = new ParseTreeWalker(); treeWalker.walk(new BConfigLangListener(runtimeConfigEntries), TomlProcessor.parseTomlContent(runtimeConfigsStream, null)); return runtimeConfigEntries; }
From source file:org.sonar.scanner.config.DefaultConfiguration.java
protected static Map<String, String> unmodifiableMapWithTrimmedValues(PropertyDefinitions definitions, Map<String, String> props) { Map<String, String> map = new HashMap<>(props.size()); props.forEach((k, v) -> { String validKey = definitions.validKey(k); map.put(validKey, trim(v));//from w w w . j a va 2s. c om }); return Collections.unmodifiableMap(map); }
From source file:org.apache.gobblin.metrics.event.lineage.LineageEventBuilder.java
/** * Create a {@link LineageEventBuilder} from a {@link GobblinEventBuilder}. An inverse function * to {@link LineageEventBuilder#build()} *///from ww w .j ava 2 s . c o m public static LineageEventBuilder fromEvent(GobblinTrackingEvent event) { Map<String, String> metadata = event.getMetadata(); LineageEventBuilder lineageEvent = new LineageEventBuilder(event.getName()); metadata.forEach((key, value) -> { switch (key) { case SOURCE: lineageEvent.setSource(Descriptor.deserialize(value)); break; case DESTINATION: lineageEvent.setDestination(Descriptor.deserialize(value)); break; default: lineageEvent.addMetadata(key, value); break; } }); return lineageEvent; }
From source file:org.apache.flink.table.client.config.entries.DeploymentEntry.java
/** * Creates a new deployment entry enriched with additional properties that are prefixed with * {@link Environment#DEPLOYMENT_ENTRY}. *///from w w w . j a v a 2s .c o m public static DeploymentEntry enrich(DeploymentEntry deployment, Map<String, String> prefixedProperties) { final Map<String, String> enrichedProperties = new HashMap<>(deployment.asMap()); prefixedProperties.forEach((k, v) -> { final String normalizedKey = k.toLowerCase(); if (k.startsWith(DEPLOYMENT_ENTRY + '.')) { enrichedProperties.put(normalizedKey.substring(DEPLOYMENT_ENTRY.length() + 1), v); } }); final DescriptorProperties properties = new DescriptorProperties(true); properties.putProperties(enrichedProperties); return new DeploymentEntry(properties); }