Tabnine Logo
Collectors.toSet
Code IndexAdd Tabnine to your IDE (free)

How to use
toSet
method
in
java.util.stream.Collectors

Best Java code snippets using java.util.stream.Collectors.toSet (Showing top 20 results out of 27,153)

Refine searchRefine arrow

  • Stream.collect
  • Stream.filter
  • Stream.map
  • Stream.of
  • Set.stream
  • List.stream
origin: apache/incubator-dubbo

protected static Set<String> getSubProperties(Map<String, String> properties, String prefix) {
  return properties.keySet().stream().filter(k -> k.contains(prefix)).map(k -> {
    k = k.substring(prefix.length());
    return k.substring(0, k.indexOf("."));
  }).collect(Collectors.toSet());
}
origin: spring-projects/spring-framework

@Override
public Set<String> keySet() {
  return this.headers.getHeaderNames().stream()
      .map(HttpString::toString)
      .collect(Collectors.toSet());
}
origin: prestodb/presto

private static <T> Set<T> union(Set<T> set1, Set<T> set2)
{
  return Stream.concat(set1.stream(), set2.stream())
      .collect(toSet());
}
origin: prestodb/presto

@Override
public List<Symbol> getOutputSymbols()
{
  return ImmutableList.<Symbol>builder()
      .addAll(groupingSets.stream()
          .flatMap(Collection::stream)
          .collect(toSet()))
      .addAll(aggregationArguments)
      .add(groupIdSymbol)
      .build();
}
origin: spring-projects/spring-framework

private static Set<HttpMethod> initAllowedHttpMethods(Set<HttpMethod> declaredMethods) {
  if (declaredMethods.isEmpty()) {
    return EnumSet.allOf(HttpMethod.class).stream()
        .filter(method -> method != HttpMethod.TRACE)
        .collect(Collectors.toSet());
  }
  else {
    Set<HttpMethod> result = new LinkedHashSet<>(declaredMethods);
    if (result.contains(HttpMethod.GET)) {
      result.add(HttpMethod.HEAD);
    }
    result.add(HttpMethod.OPTIONS);
    return result;
  }
}
origin: neo4j/neo4j

static int countUniqueValues( Object[] updates )
{
  return Stream.of( updates ).collect( Collectors.toSet() ).size();
}
origin: SonarSource/sonarqube

 static Set<Metric> extractMetrics(List<IssueMetricFormula> formulas) {
  return formulas.stream()
   .flatMap(f -> Stream.concat(Stream.of(f.getMetric()), f.getDependentMetrics().stream()))
   .collect(Collectors.toSet());
 }
}
origin: apache/incubator-dubbo

protected static Set<String> getSubProperties(Map<String, String> properties, String prefix) {
  return properties.keySet().stream().filter(k -> k.contains(prefix)).map(k -> {
    k = k.substring(prefix.length());
    return k.substring(0, k.indexOf("."));
  }).collect(Collectors.toSet());
}
origin: spring-projects/spring-framework

private Set<String> names(Class<?>... classes) {
  return stream(classes).map(Class::getName).collect(toSet());
}
origin: apache/flink

private static void verifyBroadcastPartitioning(List<Tuple2<Integer, String>> broadcastPartitionResult) {
  final Set<Tuple2<Integer, String>> expectedResult = INPUT.stream().flatMap(
    input -> IntStream.range(0, PARALLELISM).mapToObj(
      i -> Tuple2.of(i, input)))
    .collect(Collectors.toSet());
  assertEquals(
    expectedResult,
    new HashSet<>(broadcastPartitionResult));
}
origin: dropwizard/dropwizard

private static Set<Field> findAnnotatedFields(Class<?> testClass, boolean isStaticMember) {
  final Set<Field> set = Arrays.stream(testClass.getDeclaredFields()).
    filter(m -> isStaticMember == Modifier.isStatic(m.getModifiers())).
    filter(m -> DropwizardExtension.class.isAssignableFrom(m.getType())).
    collect(Collectors.toSet());
  if (!testClass.getSuperclass().equals(Object.class)) {
    set.addAll(findAnnotatedFields(testClass.getSuperclass(), isStaticMember));
  }
  return set;
}
origin: neo4j/neo4j

@Override
public Capability[] capabilities()
{
  Set<Capability> myCapabilities = Stream.of( actual.capabilities() ).collect( toSet() );
  myCapabilities.add( Capability.SECONDARY_RECORD_UNITS );
  return myCapabilities.toArray( new Capability[0] );
}
origin: prestodb/presto

private static <T> Set<T> union(Set<T> set1, Set<T> set2)
{
  return Stream.concat(set1.stream(), set2.stream())
      .collect(toSet());
}
origin: spring-projects/spring-framework

@Override
public Set<Entry<String, List<String>>> entrySet() {
  return Collections.unmodifiableSet(this.headers.entrySet().stream()
      .map(AbstractMap.SimpleImmutableEntry::new)
      .collect(Collectors.toSet()));
}
origin: apache/kafka

  private Set<String> topics() {
    return updateResponse.topicMetadata().stream()
        .map(MetadataResponse.TopicMetadata::topic)
        .collect(Collectors.toSet());
  }
}
origin: apache/incubator-druid

private Set<TaskLock> getAllLocks(List<Task> tasks)
{
 return tasks.stream()
       .flatMap(task -> taskStorage.getLocks(task.getId()).stream())
       .collect(Collectors.toSet());
}
origin: prestodb/presto

public Set<String> getAllTables(String schema)
    throws SchemaNotFoundException
{
  ImmutableSet.Builder<String> builder = ImmutableSet.builder();
  builder.addAll(ImmutableList.copyOf(client.getDatabase(schema).listCollectionNames()).stream()
      .filter(name -> !name.equals(schemaCollection))
      .filter(name -> !SYSTEM_TABLES.contains(name))
      .collect(toSet()));
  builder.addAll(getTableMetadataNames(schema));
  return builder.build();
}
origin: confluentinc/ksql

 private void givenTopicsExistInKafka(final String... topicNames) {
  when(kafkaTopicClient.listTopicNames())
    .thenReturn(Stream.of(topicNames).collect(Collectors.toSet()));
 }
}
origin: prestodb/presto

private static <T> Set<T> intersect(Set<T> set1, Set<T> set2)
{
  return set1.stream()
      .filter(set2::contains)
      .collect(toSet());
}
origin: SonarSource/sonarqube

@Test
public void selectByKeys_throws_IAE_when_keys_contains_empty_string() {
 Random random = new Random();
 Set<String> keysIncludingAnEmptyString = Stream.of(
  IntStream.range(0, random.nextInt(10)).mapToObj(i -> "b_" + i),
  Stream.of(""),
  IntStream.range(0, random.nextInt(10)).mapToObj(i -> "a_" + i))
  .flatMap(s -> s)
  .collect(Collectors.toSet());
 expectKeyNullOrEmptyIAE();
 underTest.selectByKeys(dbSession, keysIncludingAnEmptyString);
}
java.util.streamCollectorstoSet

Popular methods of Collectors

  • toList
  • joining
  • toMap
  • groupingBy
  • toCollection
  • collectingAndThen
  • counting
  • mapping
  • partitioningBy
  • reducing
  • toConcurrentMap
  • maxBy
  • toConcurrentMap,
  • maxBy,
  • summingInt,
  • summingLong,
  • groupingByConcurrent,
  • minBy,
  • summingDouble,
  • averagingInt,
  • summarizingLong

Popular in Java

  • Finding current android device location
  • getSupportFragmentManager (FragmentActivity)
  • runOnUiThread (Activity)
  • startActivity (Activity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top PhpStorm 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