- Type Parameters:
E
- the bean type
- Enclosing class:
Module
Aggregates single beans, collections of beans and arrays of beans.
- Author:
- Jeremy Kuhn
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAppends the specified bean to the aggregate.Appends the specified array of beans to the aggregate.add
(Collection<E> beans) Appends the specified collection of beans to the aggregate.E[]
toArray
(IntFunction<E[]> generator) Filters null beans and returns an array representation of the aggregate.toList()
Filters null beans and returns a list representation of the aggregate.toOptionalArray
(IntFunction<E[]> generator) Filters null beans and returns an array representation of the aggregate or an empty optional if the aggregate is empty.Filters null beans and returns a list representation of the aggregate or an empty optional if the aggregate is empty.Filters null beans and returns a set representation of the aggregate or an empty optional if the aggregate is empty.toSet()
Filters null beans and returns a set representation of the aggregate.
-
Constructor Details
-
BeanAggregator
public BeanAggregator()Creates an aggregator.
-
-
Method Details
-
add
Appends the specified bean to the aggregate.
- Parameters:
bean
- the bean to add.- Returns:
- the aggregator instance.
-
add
Appends the specified collection of beans to the aggregate.
- Parameters:
beans
- the beans to add.- Returns:
- the aggregator instance.
-
add
Appends the specified array of beans to the aggregate.
- Parameters:
beans
- the beans to add.- Returns:
- the aggregator instance.
-
toList
Filters null beans and returns a list representation of the aggregate.
- Returns:
- a list of beans
-
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
Filters null beans and returns a set representation of the aggregate.
- Returns:
- a set of beans
-
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
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
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
-