Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.bitbucket.cowwoc.guava.stream;
  
Builds a stream java.util.stream.Collector that returns an com.google.common.collect.ImmutableSetMultimap.

Parameters:
<T> the type of the input elements
<K> the type of keys stored in the map
<V> the type of values stored in the map
Author(s):
Gili Tzabari
 
 public final class ImmutableSetMultimapCollectorBuilder<T, K, V>
 	extends MultimapCollectorBuilder<T, K, V, ImmutableSetMultimap<K, V>>
 {
 	private Comparator<? super K> keysComparator;
 	private Comparator<? super V> valuesComparator;

Creates a new builder.

Parameters:
keyMapper a function that transforms the input into map keys
valueMapper a function that transforms the input into map values
supplier a function which returns a new, empty Multimap into which intermediate results will be added
characteristics the collector characteristics
Throws:
java.lang.NullPointerException if any of the arguments are null
 
 	public ImmutableSetMultimapCollectorBuilder(Function<? super T, ? extends K> keyMapper,
 		Function<? super T, ? extends V> valueMapperSupplier<Multimap<K, V>> supplier,
 		Characteristics... characteristics)
 	{
 		super(keyMappervalueMappersupplier, ImmutableSetMultimap::copyOfcharacteristics);
 	}

Sorts the map keys.

WARNING: Invoking this method overrides the finisher.

Parameters:
comparator specifies the key sorting order
Returns:
this
Throws:
java.lang.NullPointerException if comparator is null
 
 		Comparator<? super K> comparatorthrows NullPointerException
 	{
 		Preconditions.requireThat(comparator"comparator").isNotNull();
 		this. = comparator;
 		return this;
 	}

Returns:
the key sorting order
 
 	public Comparator<? super K> orderKeysBy()
 	{
 		return ;
 	}

Sorts the map values.

WARNING: Invoking this method overrides the finisher.

Parameters:
comparator specifies the value sorting order
Returns:
this
Throws:
java.lang.NullPointerException if comparator is null
 
 		Comparator<? super V> comparatorthrows NullPointerException
 	{
 		Preconditions.requireThat(comparator"comparator").isNotNull();
 		this. = comparator;
 		return this;
 	}

Returns:
the value sorting order
 
 	public Comparator<? super V> orderValuesBy()
 	{
 		return ;
 	}

WARNING: Invoking this method overrides the key and value sort order.
 
		Function<Multimap<K, V>, ImmutableSetMultimap<K, V>> finisher)
	{
		this. = null;
		this. = null;
		super.finisher(finisher);
		return this;
	}

Returns:
a new collector
	public Collector<T, ?, ImmutableSetMultimap<K, V>> build()
	{
		if ( != null ||  != null)
		{
			super.finisher(value ->
			{
				ImmutableSetMultimap.Builder<K, V> builder = ImmutableSetMultimap.<K, V>builder().
					putAll(value);
				if (keysComparator != null)
					builder.orderKeysBy(keysComparator);
				if (valuesComparator != null)
					builder.orderValuesBy(valuesComparator);
				return builder.build();
			});
		}
		return super.build();
	}
New to GrepCode? Check out our FAQ X