Class ListBuilder<U,V>

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

public class ListBuilder<U,V> extends Object
Folds a list to a single value, reached as f().list.
  • Constructor Details

    • ListBuilder

      public ListBuilder()
  • Method Details

    • reduce

      public ValueReducer<U,V> reduce(List<U> items)
      Starts a fold over a list. Continue with startingWith to supply the initial value.

      This exists because neither dialect has a natural fold: a SpEL expression cannot hold a running variable, so summing or accumulating over a collection needs this shape.

      Parameters:
      items - the list to fold; null is treated as empty
      Returns:
      a reducer awaiting an initial value

      Groovy example:
      f().list.reduce(items).startingWith(0)

      Returns:
      a reducer ready to accumulate

      SpEL example:
      #f().list.reduce(#lineItems).startingWith(0)