Class ValueReducer<U,V>

java.lang.Object
com.ssgllc.fish.f.list.ValueReducer<U,V>

public class ValueReducer<U,V> extends Object
A fold awaiting its initial value, produced by ListBuilder.reduce(java.util.List).

A null list is treated as empty, so a fold over an absent collection yields the initial value rather than failing.

  • Constructor Details

    • ValueReducer

      public ValueReducer(List<U> items)
  • Method Details

    • startingWith

      public List<ValueReducer.Reducer<U,V>> startingWith(V initialValue)
      Supplies the fold's initial value.

      Returns a single-element list rather than the reducer itself, so a SpEL projection can be used to step into it - which is how the chain continues without a statement.

      Parameters:
      initialValue - the value the fold starts from
      Returns:
      a one-element list holding the reducer