Class Module.BeanAggregator<E>

java.lang.Object
io.inverno.core.v1.Module.BeanAggregator<E>
Type Parameters:
E - the bean type
Enclosing class:
Module

protected static class Module.BeanAggregator<E> extends Object

Aggregates single beans, collections of beans and arrays of beans.

Author:
Jeremy Kuhn
  • Constructor Details

    • BeanAggregator

      public BeanAggregator()
      Creates an aggregator.
  • Method Details

    • add

      public Module.BeanAggregator<E> add(E bean)

      Appends the specified bean to the aggregate.

      Parameters:
      bean - the bean to add.
      Returns:
      the aggregator instance.
    • add

      public Module.BeanAggregator<E> add(Collection<E> beans)

      Appends the specified collection of beans to the aggregate.

      Parameters:
      beans - the beans to add.
      Returns:
      the aggregator instance.
    • add

      public Module.BeanAggregator<E> add(E[] beans)

      Appends the specified array of beans to the aggregate.

      Parameters:
      beans - the beans to add.
      Returns:
      the aggregator instance.
    • toList

      public List<E> toList()

      Filters null beans and returns a list representation of the aggregate.

      Returns:
      a list of beans
    • toOptionalList

      public Optional<List<E>> toOptionalList()

      Filters null beans and returns a list representation of the aggregate or an empty optional if the aggregate is empty.

      Returns:
      an optional containing the aggregate as a list or an empty optional
    • toSet

      public Set<E> toSet()

      Filters null beans and returns a set representation of the aggregate.

      Returns:
      a set of beans
    • toOptionalSet

      public Optional<Set<E>> toOptionalSet()

      Filters null beans and returns a set representation of the aggregate or an empty optional if the aggregate is empty.

      Returns:
      an optional containing the aggregate as a set or an empty optional
    • toArray

      public E[] toArray(IntFunction<E[]> generator)

      Filters null beans and returns an array representation of the aggregate.

      Parameters:
      generator - a function which produces a new array of the desired type and the provided length
      Returns:
      an array of beans
    • toOptionalArray

      public Optional<E[]> toOptionalArray(IntFunction<E[]> generator)

      Filters null beans and returns an array representation of the aggregate or an empty optional if the aggregate is empty.

      Parameters:
      generator - a function which produces a new array of the desired type and the provided length
      Returns:
      an optional containing the aggregate as an array or an empty optional