Package adams.data.binning.operation
Class Grouping
- java.lang.Object
-
- adams.data.binning.operation.Grouping
-
public class Grouping extends Object
For grouping Binnable and ungrouping BinnableGroup objects.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Grouping.GroupExtractor<T>
-
Constructor Summary
Constructors Constructor Description Grouping()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static <T> com.github.fracpete.javautils.struct.Struct2<List<String>,Map<String,BinnableGroup<T>>>
group(List<Binnable<T>> data, Grouping.GroupExtractor<T> extractor)
Combines the binnable items into groups based on the groups extracted.static <T> List<BinnableGroup<T>>
groupAsList(List<Binnable<T>> data, Grouping.GroupExtractor<T> extractor)
Combines the binnable items into groups based on the groups extracted.static <T> Map<String,BinnableGroup<T>>
groupAsMap(List<Binnable<T>> data, Grouping.GroupExtractor<T> extractor)
Combines the binnable items into groups based on the groups extracted.static <T> List<Binnable<T>>
ungroup(BinnableGroup<T> data)
Unravels the grouped binnable items into a single list again.static <T> List<Binnable<T>>
ungroupMap(Map<String,BinnableGroup<T>> data, boolean sortByGroup)
Unravels the grouped binnable items into a single list again.
-
-
-
Method Detail
-
group
protected static <T> com.github.fracpete.javautils.struct.Struct2<List<String>,Map<String,BinnableGroup<T>>> group(List<Binnable<T>> data, Grouping.GroupExtractor<T> extractor)
Combines the binnable items into groups based on the groups extracted.- Type Parameters:
T
- the payload type- Parameters:
data
- the data to groupextractor
- for extracting the group- Returns:
- the order of the groups and group map
-
groupAsMap
public static <T> Map<String,BinnableGroup<T>> groupAsMap(List<Binnable<T>> data, Grouping.GroupExtractor<T> extractor)
Combines the binnable items into groups based on the groups extracted.- Type Parameters:
T
- the payload type- Parameters:
data
- the data to groupextractor
- for extracting the group- Returns:
- the groups
-
groupAsList
public static <T> List<BinnableGroup<T>> groupAsList(List<Binnable<T>> data, Grouping.GroupExtractor<T> extractor)
Combines the binnable items into groups based on the groups extracted. The generated list consists of the sorted groups.- Type Parameters:
T
- the payload type- Parameters:
data
- the data to groupextractor
- for extracting the group- Returns:
- the groups
-
ungroupMap
public static <T> List<Binnable<T>> ungroupMap(Map<String,BinnableGroup<T>> data, boolean sortByGroup)
Unravels the grouped binnable items into a single list again.- Type Parameters:
T
- the payload type- Parameters:
data
- the data to ungroupsortByGroup
- whether to sort by group- Returns:
- the generated list
-
ungroup
public static <T> List<Binnable<T>> ungroup(BinnableGroup<T> data)
Unravels the grouped binnable items into a single list again.- Type Parameters:
T
- the payload type- Parameters:
data
- the data to ungroup- Returns:
- the generated list
-
-