Class SlidingCollector<T>

java.lang.Object
com.ggalmazor.ltdownsampling.tools.SlidingCollector<T>
All Implemented Interfaces:
Collector<T,List<List<T>>,List<List<T>>>

public class SlidingCollector<T> extends Object implements Collector<T,List<List<T>>,List<List<T>>>
This class implements a sliding window collector for Stream streams

Copied from ...

  • Constructor Details

    • SlidingCollector

      public SlidingCollector(int size, int step)
      Creates a new SlidingCollector instance with the provided configuration
      Parameters:
      size - the number of elements on each list element in the output list
      step - the number of input elements to skip after each list element in the output list
  • Method Details

    • supplier

      public Supplier<List<List<T>>> supplier()
      A function that creates and returns a new mutable result container.
      Specified by:
      supplier in interface Collector<T,List<List<T>>,List<List<T>>>
      Returns:
      a function which returns a new, mutable result container
    • accumulator

      public BiConsumer<List<List<T>>,T> accumulator()
      A function that folds a value into a mutable result container.
      Specified by:
      accumulator in interface Collector<T,List<List<T>>,List<List<T>>>
      Returns:
      a function which folds a value into a mutable result container
    • finisher

      public Function<List<List<T>>,List<List<T>>> finisher()
      Perform the final transformation from the intermediate accumulation type A to the final result type R.

      If the characteristic IDENTITY_FINISH is set, this function may be presumed to be an identity transform with an unchecked cast from A to R.

      Specified by:
      finisher in interface Collector<T,List<List<T>>,List<List<T>>>
      Returns:
      a function which transforms the intermediate result to the final result
    • combiner

      public BinaryOperator<List<List<T>>> combiner()
      A function that accepts two partial results and merges them. The combiner function may fold state from one argument into the other and return that, or may return a new result container.
      Specified by:
      combiner in interface Collector<T,List<List<T>>,List<List<T>>>
      Returns:
      a function which combines two partial results into a combined result
    • characteristics

      public Set<Collector.Characteristics> characteristics()
      Returns a Set of Collector.Characteristics indicating the characteristics of this Collector. This set should be immutable.
      Specified by:
      characteristics in interface Collector<T,List<List<T>>,List<List<T>>>
      Returns:
      an immutable set of collector characteristics