API Documentation: View

A view of a collection that are created and configured as they are required.

Properties

Property Description

elements

The contents of this view as a Provider of <T> instances.

Methods

Method Description

configureEach(spec, action)

Registers an action to execute to configure each element in the view matching the given specification. The action is only executed for those elements that are required. Fails if any element has already been finalized.

configureEach(action)

Registers an action to execute to configure each element in the view. The action is only executed for those elements that are required. Fails if any element has already been finalized.

configureEach(type, action)

Registers an action to execute to configure each element in the view. The action is only executed for those elements that are required. Fails if any matching element has already been finalized.

This method is equivalent to view.withType(Foo).configureEach { …​ }.

get()

Returns the contents of this view as a Set of <T> instances.

map(mapper)

Returns a list containing the results of applying the given mapper function to each element in the view.

flatMap(mapper)

Returns a single list containing all elements yielded from results of mapper function being invoked on each element of this view.

filter(spec)

Returns a single list containing all elements matching the given specification.

withType(type)

Returns a view containing the objects in this view of the given type. The returned view is live, so that when matching objects are later added to this view, they are also visible in the filtered view.

Property Details

Provider<Set<? extends T>> elements (read-only)

The contents of this view as a Provider of <T> instances.

The returned Provider is live, and tracks changes of the view.

Method Details

void configureEach(Spec<? super T> spec, Action<? super T> action)

Registers an action to execute to configure each element in the view matching the given specification. The action is only executed for those elements that are required. Fails if any element has already been finalized.

void configureEach(Action<? super T> action)

Registers an action to execute to configure each element in the view. The action is only executed for those elements that are required. Fails if any element has already been finalized.

void configureEach(Class<S> type, Action<? super S> action)

Registers an action to execute to configure each element in the view. The action is only executed for those elements that are required. Fails if any matching element has already been finalized.

This method is equivalent to view.withType(Foo).configureEach { …​ }.

Set<? extends T> get()

Returns the contents of this view as a Set of <T> instances.

Provider<List<? extends S>> map(Transformer<? extends S, ? super T> mapper)

Returns a list containing the results of applying the given mapper function to each element in the view.

The returned Provider is live, and tracks changes of the view.

Provider<List<? extends S>> flatMap(Transformer<Iterable<? extends S>, ? super T> mapper)

Returns a single list containing all elements yielded from results of mapper function being invoked on each element of this view.

The returned Provider is live, and tracks changes of the view.

Provider<List<? extends T>> filter(Spec<? super T> spec)

Returns a single list containing all elements matching the given specification.

The returned Provider is live, and tracks changes of the view.

View<S> withType(Class<S> type)

Returns a view containing the objects in this view of the given type. The returned view is live, so that when matching objects are later added to this view, they are also visible in the filtered view.