Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bitbucket.cowwoc.guava.stream;
  
  import java.util.Set;
Builds a stream java.util.stream.Collector that returns a java.util.Set.

Parameters:
<T> the type of the input elements
<R> the output type of the collector
Author(s):
Gili Tzabari
 
 public final class SetCollectorBuilder<T, R extends Set<T>>
 {
 	private Supplier<Set<T>> supplier;
 	private Function<Set<T>, R> finisher;
Creates a new builder.

Parameters:
supplier a function which returns a new, empty Set into which intermediate results will be added
finisher a function that transforms the intermediate Set into the final result
characteristics the collector characteristics
Throws:
java.lang.NullPointerException if any of the arguments are null
 
 	public SetCollectorBuilder(Supplier<Set<T>> supplierFunction<Set<T>, R> finisher,
 		Characteristics... characteristics)
 	{
 		Preconditions.requireThat(supplier"supplier").isNotNull();
 		Preconditions.requireThat(finisher"finisher").isNotNull();
 		Preconditions.requireThat(characteristics"characteristics").isNotNull();
 
 		this. = supplier;
 		this. = finisher;
 		this. = characteristics;
 	}

Returns:
a function which returns a new, empty Set into which intermediate results will be added
 
 	public Supplier<Set<T>> supplier()
 	{
 		return ;
 	}

Parameters:
supplier a function which returns a new, empty Set into which intermediate results will be added
Returns:
this
Throws:
java.lang.NullPointerException if supplier is null
 
 	public SetCollectorBuilder<T, R> supplier(Supplier<Set<T>> supplier)
 	{
 		Preconditions.requireThat(supplier"supplier").isNotNull();
 		this. = supplier;
 		return this;
 	}

Returns:
a function that transforms the intermediate Set into the final result
 
 	public Function<Set<T>, R> finisher()
 	{
 		return ;
 	}

Sets a function that transforms the intermediate Set into the final result.

Make sure to update the collector characteristics if necessary.

Parameters:
finisher a function that transforms the intermediate Set into the final result
Returns:
this
Throws:
java.lang.NullPointerException if finisher is null
 
 	public SetCollectorBuilder<T, R> finisher(Function<Set<T>, R> finisher)
 	{
 		Preconditions.requireThat(finisher"finisher").isNotNull();
 		this. = finisher;
 		return this;
 	}

Returns:
the collector characteristics
 
	@SuppressWarnings("ReturnOfCollectionOrArrayField")
	{
	}

Parameters:
characteristics the collector characteristics
Returns:
this
Throws:
java.lang.NullPointerException if characteristics is null
	@SuppressWarnings("AssignmentToCollectionOrArrayFieldFromParameter")
	public SetCollectorBuilder<T, R> characteristics(Characteristics... characteristics)
	{
		Preconditions.requireThat(characteristics"characteristics").isNotNull();
		this. = characteristics;
		return this;
	}

Returns:
a new collector
	public Collector<T, ?, R> build()
	{
		BiConsumer<Set<T>, T> accumulator = (setvalue) ->
		{
			set.add(value);
		};
		BinaryOperator<Set<T>> combiner = (leftright) ->
		{
			left.addAll(right);
			return left;
		};
		return Collector.of(accumulatorcombiner);
	}
New to GrepCode? Check out our FAQ X