java.util.Properties.forEach()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(212)

本文整理了Java中java.util.Properties.forEach()方法的一些代码示例,展示了Properties.forEach()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Properties.forEach()方法的具体详情如下:
包路径:java.util.Properties
类名称:Properties
方法名:forEach

Properties.forEach介绍

暂无

代码示例

代码示例来源:origin: apache/hive

@Override
public synchronized void forEach(BiConsumer action) {
 if (interned != null) interned.forEach(action);
 else super.forEach(action);
}

代码示例来源:origin: spring-projects/spring-framework

private static MultiValueMap<String, Entry> parseIndex(List<Properties> content) {
  MultiValueMap<String, Entry> index = new LinkedMultiValueMap<>();
  for (Properties entry : content) {
    entry.forEach((type, values) -> {
      String[] stereotypes = ((String) values).split(",");
      for (String stereotype : stereotypes) {
        index.add(stereotype, new Entry((String) type));
      }
    });
  }
  return index;
}

代码示例来源:origin: apache/storm

/**
 * Set multiple {@link KafkaConsumer} properties. 
 */
public T setProp(Properties props) {
  props.forEach((key, value) -> {
    if (key instanceof String) {
      kafkaProps.put((String) key, value);
    } else {
      throw new IllegalArgumentException("Kafka Consumer property keys must be Strings");
    }
  });
  return (T)this;
}

代码示例来源:origin: lets-blade/blade

public Map<String, String> toMap() {
  var map = new HashMap<String, String>(props.size());
  props.forEach((k, v) -> map.put(k.toString(), v.toString()));
  return map;
}

代码示例来源:origin: lets-blade/blade

public Map<String, String> toMap() {
  var map = new HashMap<String, String>(props.size());
  props.forEach((k, v) -> map.put(k.toString(), v.toString()));
  return map;
}

代码示例来源:origin: lets-blade/blade

public Environment addAll(@NonNull Properties props) {
  props.forEach((key, value) -> this.props.setProperty(key.toString(), value.toString()));
  return this;
}

代码示例来源:origin: lets-blade/blade

public Environment addAll(@NonNull Properties props) {
  props.forEach((key, value) -> this.props.setProperty(key.toString(), value.toString()));
  return this;
}

代码示例来源:origin: lets-blade/blade

public Map<String, Object> getPrefix(String key) {
  var map = new HashMap<String, Object>();
  if (null != key) {
    props.forEach((key_, value) -> {
      if (key_.toString().startsWith(key)) {
        map.put(key_.toString().substring(key.length() + 1), value);
      }
    });
  }
  return map;
}

代码示例来源:origin: spring-projects/spring-framework

public static CandidateComponentsMetadata read(InputStream in) throws IOException {
  CandidateComponentsMetadata result = new CandidateComponentsMetadata();
  Properties props = new Properties();
  props.load(in);
  props.forEach((type, value) -> {
    Set<String> candidates = new HashSet<>(Arrays.asList(((String) value).split(",")));
    result.add(new ItemMetadata((String) type, candidates));
  });
  return result;
}

代码示例来源:origin: lets-blade/blade

public Map<String, Object> getPrefix(String key) {
  var map = new HashMap<String, Object>();
  if (null != key) {
    props.forEach((key_, value) -> {
      if (key_.toString().startsWith(key)) {
        map.put(key_.toString().substring(key.length() + 1), value);
      }
    });
  }
  return map;
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Add a mapping from a key, extracted from a path extension or a query
 * parameter, to a MediaType. This is required in order for the parameter
 * strategy to work. Any extensions explicitly registered here are also
 * whitelisted for the purpose of Reflected File Download attack detection
 * (see Spring Framework reference documentation for more details on RFD
 * attack protection).
 * <p>The path extension strategy will also try to use
 * {@link ServletContext#getMimeType} and
 * {@link org.springframework.http.MediaTypeFactory} to resolve path extensions.
 * @param mediaTypes media type mappings
 * @see #addMediaType(String, MediaType)
 * @see #addMediaTypes(Map)
 */
public void setMediaTypes(Properties mediaTypes) {
  if (!CollectionUtils.isEmpty(mediaTypes)) {
    mediaTypes.forEach((key, value) -> {
      String extension = ((String) key).toLowerCase(Locale.ENGLISH);
      MediaType mediaType = MediaType.valueOf((String) value);
      this.mediaTypes.put(extension, mediaType);
    });
  }
}

代码示例来源:origin: pentaho/pentaho-kettle

@Override
public synchronized void loadFromXML( InputStream in ) throws IOException, InvalidPropertiesFormatException {
 super.putAll( storageMap );
 super.loadFromXML( in );
 super.forEach( ( key, value ) -> storageMap.putIfAbsent( key, value ) );
 super.clear();
}

代码示例来源:origin: pentaho/pentaho-kettle

@Override
public synchronized void load( Reader reader ) throws IOException {
 super.putAll( storageMap );
 super.load( reader );
 super.forEach( ( key, value ) -> storageMap.put( key, value ) );
 super.clear();
}

代码示例来源:origin: apache/hive

private Properties replacePrefix(Properties props) {
 Properties newProps = new Properties();
 props.forEach((key,value) ->
   newProps.put(key.toString().replaceFirst(HIKARI + ".", ""), value));
 return newProps;
}

代码示例来源:origin: pentaho/pentaho-kettle

@Override
public synchronized void load( InputStream inStream ) throws IOException {
 super.putAll( storageMap );
 super.load( inStream );
 super.forEach( ( key, value ) -> storageMap.put( key, value ) );
 super.clear();
}

代码示例来源:origin: org.springframework/spring-context

private static MultiValueMap<String, Entry> parseIndex(List<Properties> content) {
  MultiValueMap<String, Entry> index = new LinkedMultiValueMap<>();
  for (Properties entry : content) {
    entry.forEach((type, values) -> {
      String[] stereotypes = ((String) values).split(",");
      for (String stereotype : stereotypes) {
        index.add(stereotype, new Entry((String) type));
      }
    });
  }
  return index;
}

代码示例来源:origin: apache/flink

/**
 * Sets the configuration properties for the Kafka consumer. Resets previously set properties.
 *
 * @param properties The configuration properties for the Kafka consumer.
 */
public Kafka properties(Properties properties) {
  Preconditions.checkNotNull(properties);
  if (this.kafkaProperties == null) {
    this.kafkaProperties = new HashMap<>();
  }
  this.kafkaProperties.clear();
  properties.forEach((k, v) -> this.kafkaProperties.put((String) k, (String) v));
  return this;
}

代码示例来源:origin: SonarSource/sonarqube

public Props(Properties props) {
 this.properties = new Properties();
 props.forEach((k, v) -> this.properties.put(k.toString().trim(), v == null ? null : v.toString().trim()));
 this.encryption = new Encryption(props.getProperty(AesCipher.ENCRYPTION_SECRET_KEY_PATH));
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public Map<String, String> getProperties() {
 Map<String, String> result = new HashMap<>();
 loadAll(result);
 systemProps.forEach((key, value) -> result.put((String) key, (String) value));
 return unmodifiableMap(result);
}

代码示例来源:origin: SonarSource/sonarqube

@VisibleForTesting
ThreadLocalSettings(PropertyDefinitions definitions, Properties props, SettingLoader settingLoader) {
 super(definitions, new Encryption(null));
 this.settingLoader = settingLoader;
 props.forEach((k, v) -> systemProps.put(k, v == null ? null : v.toString().trim()));
 // TODO something wrong about lifecycle here. It could be improved
 getEncryption().setPathToSecretKey(props.getProperty(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
}

相关文章

微信公众号

最新文章

更多