java.lang.Object
de.linusdev.data.container.NonExistentContainer<K,V,O>
- All Implemented Interfaces:
Container<K,,V, O> OptionalValue<O>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull ListContainer<Object>asList()cast()Casts the value toContainer.castAndConvert(@NotNull Converter<C, R> converter) Casts the value toContainerand converts it with givenconverter.castAndConvertWithException(@NotNull ExceptionConverter<C, R, E> converter) Casts the value toContainerand converts it with givenconverter.createNewContainer(N newValue) Creates a newContainerwith given value.<T> @NotNull ListContainer<T>createNewListContainer(@Nullable List<T> newValue) Creates a newListContainerwith given value.booleanexists()get()The actual value of classOptionalValuerepresented by thisOptionalValue.getKey()@NotNull AbstractData<K,V> ifExists()If the value does notexist, a newNonExistentContainerwill be returned.booleanisNull()This method is especially useful in combination withContainer.ifExists()andContainer.requireNotNull().requireNotNull(ExceptionSupplier<K, AbstractData<K, V>, E> supplier) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.linusdev.data.OptionalValue
getAs
-
Constructor Details
-
NonExistentContainer
-
-
Method Details
-
get
Description copied from interface:OptionalValueThe actual value of classOptionalValuerepresented by thisOptionalValue.- Specified by:
getin interfaceOptionalValue<K>- Returns:
OptionalValueornull
-
isNull
public boolean isNull()- Specified by:
isNullin interfaceOptionalValue<K>- Returns:
trueifOptionalValue.get()will returnnull.
-
exists
public boolean exists()Description copied from interface:OptionalValue- Specified by:
existsin interfaceOptionalValue<K>- Returns:
trueif thisOptionalValueexists in theAbstractDatathisOptionalValueis of.
-
getKey
-
getParentData
- Specified by:
getParentDatain interfaceContainer<K,V, O> - Returns:
parent data.
-
createNewContainer
Description copied from interface:ContainerCreates a newContainerwith given value. -
createNewListContainer
@NotNull public <T> @NotNull ListContainer<T> createNewListContainer(@Nullable @Nullable List<T> newValue) Description copied from interface:ContainerCreates a newListContainerwith given value.- Specified by:
createNewListContainerin interfaceContainer<K,V, O> - Type Parameters:
T- the list-element type- Parameters:
newValue- the list value- Returns:
- a new
ListContainer
-
requireNotNull
@NotNull public <E extends Throwable> @NotNull Container<K,V, requireNotNullO> (ExceptionSupplier<K, AbstractData<K, throws EV>, E> supplier) - Specified by:
requireNotNullin interfaceContainer<K,V, O> - Type Parameters:
E- exception thrown if the value isnull.- Parameters:
supplier-ExceptionSupplierto supply an exception of your choice.- Returns:
- this
- Throws:
E- if the value isnull(OptionalValue.get()returnsnull).
-
requireNotNull
- Specified by:
requireNotNullin interfaceContainer<K,V, O> - Returns:
- this
- Throws:
NullPointerException- if the value isnull(OptionalValue.get()returnsnull).
-
asList
Description copied from interface:Container -
castAndConvert
@NotNull public <C,R> @NotNull Container<K,V, castAndConvertR> (@NotNull @NotNull Converter<C, R> converter) Description copied from interface:ContainerCasts the value toContainerand converts it with givenconverter.- Specified by:
castAndConvertin interfaceContainer<K,V, O> - Type Parameters:
C- type to cast to.R- type toConverter.convert(Object)to.- Parameters:
converter- the converter toConverter.convert(Object)fromContainertoContainer.- Returns:
- a new
Containerwith the new cast and converted value.
-
cast
Description copied from interface:ContainerCasts the value toContainer. -
castAndConvertWithException
@NotNull public <C,R, @NotNull Container<K,E extends Throwable> V, castAndConvertWithExceptionR> (@NotNull @NotNull ExceptionConverter<C, R, E> converter) Description copied from interface:ContainerCasts the value toContainerand converts it with givenconverter. The converter can throw an exception.- Specified by:
castAndConvertWithExceptionin interfaceContainer<K,V, O> - Type Parameters:
C- type to cast to.R- type toConverter.convert(Object)to.E- exception your converter may throw.- Parameters:
converter- the converter toExceptionConverter.convert(Object)fromContainertoContainer.- Returns:
- a new
Containerwith the new cast and converted value.
-
ifExists
Description copied from interface:ContainerIf the value does notexist, a newNonExistentContainerwill be returned. All Operations on this container will have no effect. This means:-
OptionalValue.get()will throw aNonExistentException. -
Container.process(Consumer)will not execute the givenConsumer. -
Container.requireNotNull()orContainer.requireNotNull(ExceptionSupplier)will never throw an exception.
If the value does
exist, theContaineritself (this) is returned.This method should be mainly used in combination with the
Container.process(Consumer)method and then functions similar toAbstractData.processIfContained(Object, Consumer), but can be combined with all other container methods. -
-
process
Description copied from interface:ContainerThis method is especially useful in combination withContainer.ifExists()andContainer.requireNotNull().
-