Tabnine Logo
Set.forEach
Code IndexAdd Tabnine to your IDE (free)

How to use
forEach
method
in
java.util.Set

Best Java code snippets using java.util.Set.forEach (Showing top 20 results out of 22,329)

Refine searchRefine arrow

  • Map.Entry.getKey
  • Map.Entry.getValue
  • Map.entrySet
  • Map.put
  • Set.add
origin: spring-projects/spring-framework

/**
 * Retrieve "known" attributes from the session, i.e. attributes listed
 * by name in {@code @SessionAttributes} or attributes previously stored
 * in the model that matched by type.
 * @param session the current session
 * @return a map with handler session attributes, possibly empty
 */
public Map<String, Object> retrieveAttributes(WebSession session) {
  Map<String, Object> attributes = new HashMap<>();
  this.knownAttributeNames.forEach(name -> {
    Object value = session.getAttribute(name);
    if (value != null) {
      attributes.put(name, value);
    }
  });
  return attributes;
}
origin: eclipse-vertx/vert.x

public static JsonObject toJsonObject(Map<String, Object> map) {
 if (map == null) {
  return null;
 }
 map = new LinkedHashMap<>(map);
 map.entrySet().forEach(e -> e.setValue(toJsonElement(e.getValue())));
 return new JsonObject(map);
}
origin: pentaho/pentaho-kettle

@Override
public synchronized Set<String> stringPropertyNames() {
 Set<String> copiedSet = new HashSet<>();
 if ( defaults != null ) {
  defaults.keySet().forEach( x -> copiedSet.add( (String) x ) );
 }
 storageMap.keySet().forEach( x -> copiedSet.add( (String) x ) );
 return copiedSet;
}
origin: knowm/XChange

@JsonCreator
public LiquiAccountFunds(final Map<String, String> funds) {
 funds
   .entrySet()
   .forEach(
     entry ->
       this.funds.put(
         Currency.getInstance(entry.getKey()), new BigDecimal(entry.getValue())));
}
origin: apache/storm

if (null != assignment) {
  Map<Integer, NodeInfo> taskToNodePort = StormCommon.taskToNodeport(assignment.get_executor_node_port());
  for (Map.Entry<Integer, NodeInfo> taskToNodePortEntry : taskToNodePort.entrySet()) {
    Integer task = taskToNodePortEntry.getKey();
    if (outboundTasks.contains(task)) {
      newTaskToNodePort.put(task, taskToNodePortEntry.getValue());
      if (!localTaskIds.contains(task)) {
        neededConnections.add(taskToNodePortEntry.getValue());
  Map<NodeInfo, IConnection> next = new HashMap<>(prev);
  for (NodeInfo nodeInfo : newConnections) {
    next.put(nodeInfo,
         mqContext.connect(
           topologyId,
  removeConnections.forEach(next::remove);
  return next;
});
origin: apache/nifi

private Set<AsyncLoadBalanceClient> registerClients(final NodeIdentifier nodeId) {
  final Set<AsyncLoadBalanceClient> clients = new HashSet<>();
  for (int i=0; i < clientsPerNode; i++) {
    final AsyncLoadBalanceClient client = clientFactory.createClient(nodeId);
    clients.add(client);
    logger.debug("Added client {} for communicating with Node {}", client, nodeId);
  }
  clientMap.put(nodeId, clients);
  allClients.addAll(clients);
  if (running) {
    clients.forEach(AsyncLoadBalanceClient::start);
  }
  return clients;
}
origin: debezium/debezium

/**
 * Create the map of predicate functions that specify which columns are to be included.
 * <p>
 * Qualified column names are comma-separated strings that are each {@link #parse(String) parsed} into {@link ColumnId} objects.
 *
 * @param columnBlacklist the comma-separated string listing the qualified names of the columns to be explicitly disallowed;
 *            may be null
 * @return the predicate function; never null
 */
public static Map<TableId,Predicate<Column>> filter(String columnBlacklist) {
  Set<ColumnId> columnExclusions = columnBlacklist == null ? null : Strings.setOf(columnBlacklist, ColumnId::parse);
  Map<TableId,Set<String>> excludedColumnNamesByTable = new HashMap<>();
  columnExclusions.forEach(columnId->{
    excludedColumnNamesByTable.compute(columnId.tableId(), (tableId,columns)->{
      if ( columns == null ) columns = new HashSet<String>();
      columns.add(columnId.columnName().toLowerCase());
      return columns;
    });
  });
  Map<TableId,Predicate<Column>> exclusionFilterByTable= new HashMap<>();
  excludedColumnNamesByTable.forEach((tableId,excludedColumnNames)->{
    exclusionFilterByTable.put(tableId, (col)->!excludedColumnNames.contains(col.name().toLowerCase()));
  });
  return exclusionFilterByTable;
}
origin: stanfordnlp/CoreNLP

/**
 * Get the coreference chain for just this sentence.
 * Note that this method is actually fairly computationally expensive to call, as it constructs and prunes
 * the coreference data structure for the entire document.
 *
 * @return A coreference chain, but only for this sentence
 */
public Map<Integer, CorefChain> coref() {
 // Get the raw coref structure
 Map<Integer, CorefChain> allCorefs = document.coref();
 // Delete coreference chains not in this sentence
 Set<Integer> toDeleteEntirely = new HashSet<>();
 for (Map.Entry<Integer, CorefChain> integerCorefChainEntry : allCorefs.entrySet()) {
  CorefChain chain = integerCorefChainEntry.getValue();
  List<CorefChain.CorefMention> mentions = new ArrayList<>(chain.getMentionsInTextualOrder());
  mentions.stream().filter(m -> m.sentNum != this.sentenceIndex() + 1).forEach(chain::deleteMention);
  if (chain.getMentionsInTextualOrder().isEmpty()) {
   toDeleteEntirely.add(integerCorefChainEntry.getKey());
  }
 }
 // Clean up dangling empty chains
 toDeleteEntirely.forEach(allCorefs::remove);
 // Return
 return allCorefs;
}
origin: hs-web/hsweb-framework

ignore.addAll(defaultIgnoreProperties);
for (Map.Entry<String, Object> entry : newMap.entrySet()) {
  Object value = entry.getValue();
  if (simpleTypePredicate.test(type)) {
    value = simpleConvertBuilder.apply(type).apply(value, null);
    if (ignoreProperty.contains(entry.getKey())) {
      if (cover) {
        value = coverStringConvert.apply(value);
      } else {
        ignore.add(entry.getKey());
      ignore.add(entry.getKey());
ignore.forEach(newMap::remove);
return newMap;
origin: Netflix/conductor

@Override
public Map<String, Object> getAll() {
  Map<String, Object> map = new HashMap<>();
  Properties props = System.getProperties();
  props.entrySet().forEach(entry -> map.put(entry.getKey().toString(), entry.getValue()));
  map.putAll(testProperties);
  return map;
}
origin: jersey/jersey

@Override
public Set<Type> getTypes() {
  Set<Type> contracts = new HashSet<>();
  contracts.addAll(binding.getContracts());
  // Merge aliases with the main bean
  if (!binding.getAliases().isEmpty()) {
    binding.getAliases().forEach(alias -> contracts.add(alias.getContract()));
  }
  contracts.add(Object.class);
  return contracts;
}
origin: apache/incubator-druid

@Override
public void assign(Set<StreamPartition<String>> collection)
{
 checkIfClosed();
 collection.forEach(
   streamPartition -> partitionResources.putIfAbsent(
     streamPartition,
     new PartitionResource(streamPartition)
   )
 );
 for (Iterator<Map.Entry<StreamPartition<String>, PartitionResource>> i = partitionResources.entrySet()
                                               .iterator(); i.hasNext(); ) {
  Map.Entry<StreamPartition<String>, PartitionResource> entry = i.next();
  if (!collection.contains(entry.getKey())) {
   i.remove();
   entry.getValue().stopBackgroundFetch();
  }
 }
}
origin: mpusher/mpush

@Test
public void testLoad() {
  Map<String, String> map = new HashMap<>();
  CC.cfg.entrySet().forEach(e -> print(e.getKey(), e.getValue(), map));
  List<String> list = new ArrayList<>(map.values());
  Collections.sort(list);
  list.forEach(s -> System.out.println(s.substring(s.indexOf(".") + 1) + ","));
}
origin: apache/incubator-dubbo

public static Map<String, String> parseProperties(String content) throws IOException {
  Map<String, String> map = new HashMap<>();
  if (StringUtils.isEmpty(content)) {
    logger.warn("You specified the config centre, but there's not even one single config item in it.");
  } else {
    Properties properties = new Properties();
    properties.load(new StringReader(content));
    properties.stringPropertyNames().forEach(
        k -> map.put(k, properties.getProperty(k))
    );
  }
  return map;
}
origin: Netflix/conductor

public Map<Status, String> queues() {
  Map<Status, String> size = new HashMap<>();
  queues.entrySet().forEach(e -> {
    ObservableQueue queue = e.getValue();
    size.put(e.getKey(), queue.getURI());	
  });
  return size;
}
origin: requery/requery

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    errors.entrySet().forEach(entry ->
        sb.append(entry.getKey().getSimpleName())
         .append(" : ")
         .append(entry.getValue()));
    return sb.toString();
  }
}
origin: apache/kafka

Set<TopicPartition> topicPartitions = new HashSet<>();
for (int i = 0; i < numPartitions; i++)
  topicPartitions.add(new TopicPartition(topicName, i));
topicPartitions.forEach(tp -> subscriptions.seek(tp, 0L));
        FetchRequest fetchRequest = (FetchRequest) request.requestBuilder().build();
        LinkedHashMap<TopicPartition, FetchResponse.PartitionData<MemoryRecords>> responseMap = new LinkedHashMap<>();
        for (Map.Entry<TopicPartition, FetchRequest.PartitionData> entry : fetchRequest.fetchData().entrySet()) {
          TopicPartition tp = entry.getKey();
          long offset = entry.getValue().fetchOffset;
          responseMap.put(tp, new FetchResponse.PartitionData<>(Errors.NONE, offset + 2L, offset + 2,
              0L, null, buildRecords(offset, 2, offset)));
    if (!fetchedRecords.isEmpty()) {
      fetchesRemaining.decrementAndGet();
      fetchedRecords.entrySet().forEach(entry -> {
        TopicPartition tp = entry.getKey();
        List<ConsumerRecord<byte[], byte[]>> records = entry.getValue();
        assertEquals(2, records.size());
        long nextOffset = nextFetchOffsets.get(tp);
        assertEquals(nextOffset, records.get(0).offset());
        assertEquals(nextOffset + 1, records.get(1).offset());
        nextFetchOffsets.put(tp, nextOffset + 2);
      });
origin: jooby-project/jooby

@Inject
public MetricRegistryInitializer(final MetricRegistry registry, final Map<String, Metric> metrics,
  final Set<Reporter> reporters) {
 metrics.forEach(registry::register);
 reporters.forEach(reporter -> {
  if (reporter instanceof Closeable) {
   this.reporters.add((Closeable) reporter);
  }
 });
}
origin: hs-web/hsweb-framework

Set<String> realIgnore = new HashSet<>();
for (Map.Entry<String, Object> entry : map.entrySet()) {
  Object value = entry.getValue();
  if (value == null) {
    if (ToString.Feature.hasFeature(features, ToString.Feature.nullPropertyToEmpty)) {
      boolean isSimpleType = false;
      PropertyDescriptor propertyDescriptor = descriptorMap.get(entry.getKey());
      Class propertyType = null;
      if (propertyDescriptor != null) {
  BiFunction<Object, ConvertConfig, Object> converter = converts.get(entry.getKey());
  if (null != converter) {
    entry.setValue(converter.apply(value, convertConfig));
  if (entry.getValue() == null) {
    realIgnore.add(entry.getKey());
realIgnore.forEach(map::remove);
origin: apache/incubator-dubbo

public static Map<String, String> parseProperties(String content) throws IOException {
  Map<String, String> map = new HashMap<>();
  if (StringUtils.isEmpty(content)) {
    logger.warn("You specified the config centre, but there's not even one single config item in it.");
  } else {
    Properties properties = new Properties();
    properties.load(new StringReader(content));
    properties.stringPropertyNames().forEach(
        k -> map.put(k, properties.getProperty(k))
    );
  }
  return map;
}
java.utilSetforEach

Popular methods of Set

  • add
    Adds the specified element to this set if it is not already present (optional operation). More forma
  • contains
    Returns true if this set contains the specified element. More formally, returns true if and only if
  • iterator
    Returns an iterator over the elements in this set. The elements are returned in no particular order
  • size
  • isEmpty
    Returns true if this set contains no elements.
  • addAll
    Adds all of the elements in the specified collection to this set if they're not already present (opt
  • remove
    Removes the specified element from this set if it is present (optional operation). More formally, re
  • toArray
    Returns an array containing all of the elements in this set; the runtime type of the returned array
  • stream
  • clear
    Removes all of the elements from this set (optional operation). The set will be empty after this cal
  • removeAll
    Removes from this set all of its elements that are contained in the specified collection (optional o
  • equals
    Compares the specified object with this set for equality. Returnstrue if the specified object is als
  • removeAll,
  • equals,
  • containsAll,
  • retainAll,
  • hashCode,
  • removeIf,
  • parallelStream,
  • spliterator,
  • of

Popular in Java

  • Running tasks concurrently on multiple threads
  • runOnUiThread (Activity)
  • setContentView (Activity)
  • getSharedPreferences (Context)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Menu (java.awt)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now