Tabnine Logo
HashSet.stream
Code IndexAdd Tabnine to your IDE (free)

How to use
stream
method
in
java.util.HashSet

Best Java code snippets using java.util.HashSet.stream (Showing top 20 results out of 990)

origin: apache/pulsar

public static List<String> topicsListsMinus(List<String> list1, List<String> list2) {
  HashSet<String> s1 = new HashSet<>(list1);
  s1.removeAll(list2);
  return s1.stream().collect(Collectors.toList());
}
origin: jersey/jersey

  private Set<E> getDiff(Set<? extends E> set1, Set<? extends E> set2) {
    HashSet<E> hashSet = new HashSet<>();
    hashSet.addAll(set1);
    hashSet.addAll(set2);
    return hashSet.stream().filter(new Predicate<E>() {
      @Override
      public boolean test(E e) {
        return set1.contains(e) && !set2.contains(e);
      }
    }).collect(Collectors.toSet());
  }
};
origin: jersey/jersey

  private Set<E> getDiff(Set<? extends E> set1, Set<? extends E> set2) {
    HashSet<E> hashSet = new HashSet<>();
    hashSet.addAll(set1);
    hashSet.addAll(set2);
    return hashSet.stream().filter(new Predicate<E>() {
      @Override
      public boolean test(E e) {
        return set1.contains(e) && !set2.contains(e);
      }
    }).collect(Collectors.toSet());
  }
};
origin: SonarSource/sonarqube

private static List<String> sanitizeScmAccounts(@Nullable List<String> scmAccounts) {
 if (scmAccounts != null) {
  return new HashSet<>(scmAccounts).stream()
   .map(Strings::emptyToNull)
   .filter(Objects::nonNull)
   .sorted(String::compareToIgnoreCase)
   .collect(toList(scmAccounts.size()));
 }
 return Collections.emptyList();
}
origin: GlowstoneMC/Glowstone

@Override
@Deprecated
public Set<OfflinePlayer> getPlayers() throws IllegalStateException {
  Set<OfflinePlayer> playerObjectSet = new HashSet<>(players.size());
  playerObjectSet.addAll(
    players.stream().map(Bukkit::getOfflinePlayer).collect(Collectors.toList()));
  return playerObjectSet;
}
origin: neo4j/neo4j

private void warnAboutDeprecatedConnectors( @Nonnull Map<String,String> connectorSettings,
    @Nonnull Consumer<String> warningConsumer )
{
  final HashSet<String> nonDefaultConnectors = new HashSet<>();
  connectorSettings.entrySet().stream()
      .map( Entry::getKey )
      .filter( settingKey ->
      {
        String name = settingKey.split( "\\." )[2];
        return isDeprecatedConnectorName( name );
      } )
      .forEach( nonDefaultConnectors::add );
  if ( !nonDefaultConnectors.isEmpty() )
  {
    warningConsumer.accept( format(
        DEPRECATED_CONNECTOR_MSG,
        nonDefaultConnectors.stream()
            .sorted()
            .map( s -> format( ">  %s%n", s ) )
            .collect( joining() ) ) );
  }
}
origin: GlowstoneMC/Glowstone

private List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance, int maxLength) {
  Set<Material> materials = transparent.stream().map(Material::getMaterial)
      .collect(Collectors.toSet());
  return getLineOfSight(materials, maxDistance, maxLength);
}
origin: RichardWarburton/java-8-lambdas-exercises

@GenerateMicroBenchmark
public int serialHashSet() {
  return hashSet.stream().mapToInt(i -> i).sum();
}
origin: hs-web/hsweb-framework

protected void trySyncUserRole(final String userId, final List<String> roleIdList) {
  new HashSet<>(roleIdList).stream()
      .map(roleId -> {
        UserRoleEntity roleEntity = entityFactory.newInstance(UserRoleEntity.class);
        roleEntity.setRoleId(roleId);
        roleEntity.setUserId(userId);
        return roleEntity;
      })
      .forEach(userRoleDao::insert);
}
origin: confluentinc/ksql

public List<URL> getListeners() {
 return Arrays.stream(server.getConnectors())
   .filter(connector -> connector instanceof ServerConnector)
   .map(ServerConnector.class::cast)
   .map(connector -> {
    try {
     final String protocol = new HashSet<>(connector.getProtocols())
       .stream()
       .map(String::toLowerCase)
       .anyMatch(s -> s.equals("ssl")) ? "https" : "http";
     final int localPort = connector.getLocalPort();
     return new URL(protocol, "localhost", localPort, "");
    } catch (final Exception e) {
     throw new RuntimeException("Malformed listener", e);
    }
   })
   .collect(Collectors.toList());
}
origin: checkstyle/checkstyle

int foo(int y) {
  MathOperation case1 = (x) -> x + x;
  MathOperation case2 = (x) -> { return x + x; };
  MathOperation case3 = (int x) -> x + x;
  MathOperation case4 = x -> x + x;
  MathOperation2 case5 = (a, b) -> a + b;
  MathOperation2 case6 = (int a, int b) -> a + b;
  MathOperation2 case7 = (int a, int b) -> { return a + b; };
  Objects.requireNonNull(null, () -> "message");
  call((x) -> x + x);
  new HashSet<Integer>().stream().filter((filter) -> filter > 0);
  return y;
}
origin: stanfordnlp/CoreNLP

new HashSet<>(props.keySet()).stream().filter(key -> !key.toString().startsWith("openie.")).forEach(key -> props.setProperty("openie." + key.toString(), props.getProperty(key.toString())));
origin: runelite/runelite

e.getValue().setLocation("<html>" + locs.stream().collect(Collectors.joining("<br>")) + "</html>");
origin: checkstyle/checkstyle

new HashSet<>(properties).stream()
  .filter(prop -> UNDOCUMENTED_PROPERTIES.contains(clss.getSimpleName() + "." + prop))
  .forEach(properties::remove);
origin: apache/tinkerpop

/**
 * Returns a list whose elements are instances of all the {@link GremlinScriptEngineFactory} classes
 * found by the discovery mechanism.
 *
 * @return List of all discovered {@link GremlinScriptEngineFactory} objects.
 */
@Override
public List<GremlinScriptEngineFactory> getEngineFactories() {
  final List<GremlinScriptEngineFactory> res = new ArrayList<>(engineSpis.size());
  res.addAll(engineSpis.stream().collect(Collectors.toList()));
  return Collections.unmodifiableList(res);
}
origin: ahmetaa/zemberek-nlp

/**
 * Generates a new LmVocabulary instance that contains words that exist in both `v1` and `v2`
 * There is no guarantee that new vocabulary indexes will match with v1 or v2.
 */
public static LmVocabulary intersect(LmVocabulary v1, LmVocabulary v2) {
 HashSet<String> ls = new HashSet<>(v1.vocabulary);
 List<String> intersection = new ArrayList<>(Math.min(v1.size(), v2.size()));
 intersection.addAll(new HashSet<>(v2.vocabulary)
   .stream()
   .filter(ls::contains)
   .collect(Collectors.toList()));
 return new LmVocabulary(intersection);
}
origin: apache/accumulo

@Override
public void addSummarizers(String tableName, SummarizerConfiguration... newConfigs)
  throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
 HashSet<SummarizerConfiguration> currentConfigs = new HashSet<>(
   SummarizerConfiguration.fromTableProperties(getProperties(tableName)));
 HashSet<SummarizerConfiguration> newConfigSet = new HashSet<>(Arrays.asList(newConfigs));
 newConfigSet.removeIf(currentConfigs::contains);
 Set<String> newIds = newConfigSet.stream().map(SummarizerConfiguration::getPropertyId)
   .collect(toSet());
 for (SummarizerConfiguration csc : currentConfigs) {
  if (newIds.contains(csc.getPropertyId())) {
   throw new IllegalArgumentException("Summarizer property id is in use by " + csc);
  }
 }
 Set<Entry<String,String>> es = SummarizerConfiguration.toTableProperties(newConfigSet)
   .entrySet();
 for (Entry<String,String> entry : es) {
  setProperty(tableName, entry.getKey(), entry.getValue());
 }
}
origin: rakam-io/rakam

missingPartitions = new HashSet<>();
String values = set.stream().map(item -> format("('%s')", item)).collect(Collectors.joining(", "));
ResultSet resultSet = statement.executeQuery(format("select part from (VALUES%s) data (part) where part not in (\n" +
    "\tselect substring(cchild.relname, %d)  from pg_catalog.pg_class c \n" +
origin: org.glassfish.jersey.core/jersey-common

  private Set<E> getDiff(Set<? extends E> set1, Set<? extends E> set2) {
    HashSet<E> hashSet = new HashSet<>();
    hashSet.addAll(set1);
    hashSet.addAll(set2);
    return hashSet.stream().filter(new Predicate<E>() {
      @Override
      public boolean test(E e) {
        return set1.contains(e) && !set2.contains(e);
      }
    }).collect(Collectors.toSet());
  }
};
origin: usethesource/capsule

@Property(trials = DEFAULT_TRIALS)
public void containsAfterInsert(@Size(min = 0, max = 0) final CT emptySet,
  @Size(min = 1, max = MAX_SIZE) final java.util.HashSet<T> inputValues) {
 CT testSet = emptySet;
 for (T newValue : inputValues) {
  final CT tmpSet = (CT) testSet.__insert(newValue);
  testSet = tmpSet;
 }
 boolean containsInsertedValues = inputValues.stream().allMatch(testSet::contains);
 assertTrue("Must contain all inserted values.", containsInsertedValues);
}
java.utilHashSetstream

Popular methods of HashSet

  • <init>
  • add
    Adds the specified element to this set if it is not already present. More formally, adds the specifi
  • contains
    Returns true if this set contains the specified element. More formally, returns true if and only if
  • size
    Returns the number of elements in this set (its cardinality).
  • addAll
  • remove
    Removes the specified element from this set if it is present. More formally, removes an element e su
  • iterator
    Returns an iterator over the elements in this set. The elements are returned in no particular order.
  • isEmpty
    Returns true if this set contains no elements.
  • clear
    Removes all of the elements from this set. The set will be empty after this call returns.
  • toArray
  • removeAll
  • equals
  • removeAll,
  • equals,
  • clone,
  • retainAll,
  • containsAll,
  • forEach,
  • hashCode,
  • toString,
  • removeIf

Popular in Java

  • Reading from database using SQL prepared statement
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • addToBackStack (FragmentTransaction)
  • compareTo (BigDecimal)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Top Sublime Text 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