Class ValueContainer.Empty<T>
java.lang.Object
ru.progrm_jarvis.javacommons.object.ValueContainer.Empty<T>
- Type Parameters:
T- type of stored value
- All Implemented Interfaces:
Supplier<T>,ValueContainer<T>
- Enclosing interface:
- ValueContainer<T>
Empty value-container.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ru.progrm_jarvis.javacommons.object.ValueContainer
ValueContainer.Containing<T>, ValueContainer.Empty<T>, ValueContainer.EmptyValueException, ValueContainer.OfNull<T>, ValueContainer.Supplying<T> -
Method Summary
Modifier and TypeMethodDescriptionasResult()Converts this value container into anull-error result.Converts this value container into aResult.get()Gets the value stored in this value container.booleanChecks whether the object is present ot not.Gets the value if it is present otherwise using the specified one.Gets the value if it is present otherwise using the one got from the specified supplier.orElseThrow(@NonNull Supplier<X> exceptionSupplier) Gets the value if it is present otherwise throwing an exception.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ru.progrm_jarvis.javacommons.object.ValueContainer
orElseSneakyThrow
-
Method Details
-
isPresent
public boolean isPresent()Description copied from interface:ValueContainerChecks whether the object is present ot not.- Specified by:
isPresentin interfaceValueContainer<T>- Returns:
trueif the value is present (might benull) andfalseotherwise
-
get
Description copied from interface:ValueContainerGets the value stored in this value container. -
orElse
Description copied from interface:ValueContainerGets the value if it is present otherwise using the specified one.- Specified by:
orElsein interfaceValueContainer<T>- Parameters:
value- value to use if this value container is empty- Returns:
- this value container's value if it is not empty or the specified value otherwise
-
orElseGet
Description copied from interface:ValueContainerGets the value if it is present otherwise using the one got from the specified supplier.- Specified by:
orElseGetin interfaceValueContainer<T>- Parameters:
defaultValueSupplier- supplier to be used for getting the value if this value container is empty- Returns:
- this value container's value if it is not empty or the one got from the supplier otherwise
-
orElseThrow
@Nullable public <X extends Throwable> T orElseThrow(@NonNull @NonNull Supplier<X> exceptionSupplier) throws X Description copied from interface:ValueContainerGets the value if it is present otherwise throwing an exception.- Specified by:
orElseThrowin interfaceValueContainer<T>- Type Parameters:
X- type of an exception thrown if this value container is empty- Parameters:
exceptionSupplier- supplier to be used for getting the exception if this value container is empty- Returns:
- this value container's value if it is not empty
- Throws:
X- if this value container is empty
-
asResult
Description copied from interface:ValueContainerConverts this value container into anull-error result.- Specified by:
asResultin interfaceValueContainer<T>- Type Parameters:
E- type of the result error- Returns:
successful resultcontaining the value contained by this value container if is ispresentor anull-error resultotherwise- See Also:
-
asResult
Description copied from interface:ValueContainerConverts this value container into aResult.- Specified by:
asResultin interfaceValueContainer<T>- Type Parameters:
E- type of the result error- Parameters:
errorSupplier- supplier of the error in case of this value container being empty- Returns:
successful resultcontaining the value contained by this value container if is ispresentor anerror resultwith the error got by using the specified supplier- See Also:
-
toString
-