Class LargestSliceCollector<E,N extends Number & Comparable<? super N>>

java.lang.Object
org.consensusj.analytics.util.collector.LargestSliceCollector<E,N>
Type Parameters:
E - The type of objects
N - The subclass of Number to use, must be Comparable
All Implemented Interfaces:
Collector<E,LargestSliceAccumulator<E,N>,LargestSliceList<E,N>>

public class LargestSliceCollector<E,N extends Number & Comparable<? super N>> extends Object implements Collector<E,LargestSliceAccumulator<E,N>,LargestSliceList<E,N>>
Collector that collects the n objects containing the "largest slices" of an input stream of type <E>. Each object must have a numeric "slice size" of type <N> determined by a sliceSizeExtractor provided to the constructor. The result is a LargestSliceList containing the n largest slices (LargestSliceList.getSliceList()) and the sum of the slice sizes (LargestSliceList.getTotalOther()) of the filtered/excluded objects. The idea is the results can easily be converted to a Pie Chart.

The objects streamed must be unique, non-null, and a sliceSizeExtractor must be provided that will return a Comparable subclass of Number. The internal LargestSliceAccumulator is a mutable implementation of LargestSliceList

Note: Be careful to use only a single sliceSizeExtractor or you can end up with LargestSliceList objects with incompatible search orders (comparators).