THING - The type of thing.public interface OptionalThing<THING>
| 修飾子とタイプ | メソッドと説明 |
|---|---|
void |
alwaysPresent(OptionalThingConsumer<? super THING> oneArgLambda)
Handle the thing in the optional thing or (detail message) exception if not present.
|
static <EMPTY> OptionalThing<EMPTY> |
empty() |
OptionalThing<THING> |
filter(OptionalThingPredicate<? super THING> oneArgLambda)
Filter the thing by the predicate.
|
<RESULT> OptionalThing<RESULT> |
flatMap(OptionalThingFunction<? super THING,OptionalThing<RESULT>> oneArgLambda)
Apply the flat-mapping of thing to result thing.
|
THING |
get()
Get the thing or (detail message) exception if not present.
|
OptionalThingIfPresentAfter |
ifPresent(OptionalThingConsumer<? super THING> oneArgLambda)
Handle the wrapped thing if it is present.
|
void |
ifPresentOrElse(OptionalThingConsumer<? super THING> oneArgLambda,
IndependentProcessor noArgLambda)
Handle the wrapped thing if it is both present and empty.
|
boolean |
isEmpty()
Is the object instance empty?
|
boolean |
isPresent()
Is the object instance present?
|
<RESULT> OptionalThing<RESULT> |
map(OptionalThingFunction<? super THING,? extends RESULT> oneArgLambda)
Apply the mapping of thing to result thing.
|
static <THING> OptionalThing<THING> |
migratedFrom(Optional<THING> java8opt,
OptionalThingExceptionThrower noArgLambda) |
static <THING> OptionalThing<THING> |
of(THING object) |
static <THING> OptionalThing<THING> |
ofNullable(THING object,
OptionalThingExceptionThrower noArgLambda) |
OptionalThing<THING> |
or(OptionalThingSupplier<? extends OptionalThing<? extends THING>> noArgLambda)
Switch this to other optional if not present.
|
THING |
orElse(THING other)
Get the wrapped instance or returns the specified thing.
|
THING |
orElseGet(OptionalThingSupplier<? extends THING> noArgLambda)
Get the thing or get from the supplier.
|
THING |
orElseThrow()
Get the thing or throw the embedded exception.
|
<CAUSE extends Throwable> |
orElseThrow(OptionalThingSupplier<? extends CAUSE> noArgLambda)
Get the thing or throw the exception.
|
<CAUSE extends Throwable,TRANSLATED extends Throwable> |
orElseTranslatingThrow(OptionalThingFunction<CAUSE,TRANSLATED> causeLambda)
Get the thing or throw the exception with translating the cause.
|
Stream<THING> |
stream()
Handle the optional thing as stream.
|
Optional<THING> |
toOptional()
Convert to Java standard optional class.
|
static <THING> OptionalThing<THING> |
translatedFrom(OptionalThing<THING> dfopt,
OptionalThingExceptionThrower noArgLambda) |
static <EMPTY> OptionalThing<EMPTY> empty()
EMPTY - The type of empty optional thing.static <THING> OptionalThing<THING> of(THING object)
THING - The type of thing wrapped in the optional thing.object - The wrapped thing which is optional. (NotNull)static <THING> OptionalThing<THING> ofNullable(THING object, OptionalThingExceptionThrower noArgLambda)
THING - The type of thing wrapped in the optional thing.object - The wrapped instance or thing. (NullAllowed)noArgLambda - The callback for exception when illegal access. (NotNull)static <THING> OptionalThing<THING> migratedFrom(Optional<THING> java8opt, OptionalThingExceptionThrower noArgLambda)
THING - The type of thing wrapped in the optional thing.java8opt - The optional instance as Java8 standard optional. (NotNull)noArgLambda - The callback for exception when illegal access. (NotNull)static <THING> OptionalThing<THING> translatedFrom(OptionalThing<THING> dfopt, OptionalThingExceptionThrower noArgLambda)
THING - The type of thing wrapped in the optional thing.dfopt - The optional instance as optional thing DBFlute provides. (NotNull)noArgLambda - The callback for exception when illegal access. (NotNull)OptionalThingIfPresentAfter ifPresent(OptionalThingConsumer<? super THING> oneArgLambda)
oneArgLambda - The callback interface to consume the optional thing. (NotNull)void ifPresentOrElse(OptionalThingConsumer<? super THING> oneArgLambda, IndependentProcessor noArgLambda)
oneArgLambda - The present-case callback interface to consume the optional thing. (NotNull)noArgLambda - The empty-case callback interface to handle or-else. (NotNull)boolean isPresent()
boolean isEmpty()
THING get()
RuntimeException - When not present, which means object is already deleted (not found).OptionalThing<THING> or(OptionalThingSupplier<? extends OptionalThing<? extends THING>> noArgLambda)
noArgLambda - The supplier of other optional if not present. (NotNull)THING orElse(THING other)
other - The object instance to be returned when the optional is empty. (NullAllowed)THING orElseGet(OptionalThingSupplier<? extends THING> noArgLambda)
noArgLambda - The supplier of other instance if not present. (NotNull)THING orElseThrow()
RuntimeException - When not present, which means object is already deleted (not found).<CAUSE extends Throwable> THING orElseThrow(OptionalThingSupplier<? extends CAUSE> noArgLambda) throws CAUSE extends Throwable
CAUSE - The type of cause.noArgLambda - The supplier of exception if not present. (NotNull)CAUSE - When the value is null.CAUSE extends Throwable<CAUSE extends Throwable,TRANSLATED extends Throwable> THING orElseTranslatingThrow(OptionalThingFunction<CAUSE,TRANSLATED> causeLambda) throws TRANSLATED extends Throwable
OptionalThing<String> optSea = ... String sea = optSea.orElseTranslatingThrow(cause -> { return new YourBusinessException("...", cause); // you can wrap the detail exception }
CAUSE - The type of original cause.TRANSLATED - The type of translated cause.causeLambda - The translator function of cause exception if not present, returning your exception. (NotNull)TRANSLATED - When the value is null.TRANSLATED extends ThrowableOptionalThing<THING> filter(OptionalThingPredicate<? super THING> oneArgLambda)
oneArgLambda - The callback to predicate whether the object is remained. (NotNull)<RESULT> OptionalThing<RESULT> map(OptionalThingFunction<? super THING,? extends RESULT> oneArgLambda)
RESULT - The type of mapping result.oneArgLambda - The callback interface to apply, null return allowed as empty. (NotNull)<RESULT> OptionalThing<RESULT> flatMap(OptionalThingFunction<? super THING,OptionalThing<RESULT>> oneArgLambda)
RESULT - The type of mapping result.oneArgLambda - The callback interface to apply, cannot return null. (NotNull)Stream<THING> stream()
void alwaysPresent(OptionalThingConsumer<? super THING> oneArgLambda)
memberBhv.selectEntity(cb -> { cb.setupSelect_MemberStatus(); cb.query().setMemberId_Equal(1); }).alwaysPresent(member -> { // called if value exists, or exception ... = member.getMemberName(); member.getMemberStatus().alwaysPresent(status -> { // also relationship ... = status.getMemberStatusName(); }); });
oneArgLambda - The callback interface to consume the optional thing. (NotNull)RuntimeException - When not present, which means object is already deleted (not found).Copyright © 2014–2021 The DBFlute Project. All rights reserved.