- Type Parameters:
T-
- All Superinterfaces:
OptionalValue<List<T>>
- All Known Implementing Classes:
ListContainerImpl,NonExistentListContainer
This class holds a
List value from an AbstractData. It offers
several methods to process the elements of this list and functions similar to it's
single value counterpart: Container.-
Method Summary
Modifier and TypeMethodDescriptiondefault <C> @NotNull ListContainer<C>cast()Casts each element of the list toListContainer.default <C,R> @NotNull ListContainer<R> castAndConvert(@NotNull Converter<C, R> converter) Casts each element of the list toListContainerand then converts it with given converter.default <C,R, E extends Throwable>
@NotNull ListContainer<R>castAndConvertWithException(@NotNull ExceptionConverter<C, R, E> converter) Casts each element of the list toListContainerand then converts it with given converter.<N> @NotNull ListContainer<N>Creates a newcontainerwith given value.default @NotNull ListContainer<T>Process this container's list with givenConsumer.Methods inherited from interface de.linusdev.data.OptionalValue
exists, get, getAs, isNull
-
Method Details
-
createNew
Creates a newcontainerwith given value.- Type Parameters:
N- the new value type.- Parameters:
newValue- the value for the new container- Returns:
- a new
ListContainer.
-
cast
Casts each element of the list toListContainer.- Type Parameters:
C- the type to cast to.- Returns:
- a new
ListContainercontaining theListofListContainer. - Throws:
ClassCastException- if any element inside this container's list cannot be cast toListContainer.
-
castAndConvert
@NotNull default <C,R> @NotNull ListContainer<R> castAndConvert(@NotNull @NotNull Converter<C, R> converter) Casts each element of the list toListContainerand then converts it with given converter.- Type Parameters:
C- type to cast to.R- type to convert to.- Parameters:
converter-Containerto convert fromListContainertoListContainer.- Returns:
- a new
ListContainercontaining theListofListContainer. - Throws:
ClassCastException- if any element inside this container's list cannot be cast toListContainer,
-
castAndConvertWithException
@NotNull default <C,R, @NotNull ListContainer<R> castAndConvertWithExceptionE extends Throwable> (@NotNull @NotNull ExceptionConverter<C, R, throws EE> converter) Casts each element of the list toListContainerand then converts it with given converter.- Type Parameters:
C- type to cast to.R- type to convert to.E- exception type of yourExceptionConverter.- Parameters:
converter-Containerto convert fromListContainertoListContainer.- Returns:
- a new
ListContainercontaining theListofListContainer. - Throws:
ClassCastException- if any element inside this container's list cannot be cast toListContainer.E- if your converter throws this exception.
-
process
Process this container's list with givenConsumer.- Parameters:
consumer- to consume this list.- Returns:
- this
-