T - the type Tpublic final class Holder<T> extends Object
non-thread-safe
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> Holder<T> |
empty() |
boolean |
equals(Object obj) |
Holder<T> |
filter(Predicate<? super T> predicate) |
T |
get() |
int |
hashCode() |
void |
ifPresent(Consumer<? super T> consumer) |
boolean |
isEmpty()
Returns the holder value whether null
|
<U> Holder<U> |
map(Function<? super T,? extends U> mapper) |
static <T> Holder<T> |
of(T value) |
T |
orElse(T other) |
T |
orElseGet(Supplier<T> other) |
<E extends Throwable> |
orElseThrow(Supplier<? extends E> exceptionSupplier) |
T |
set(T value)
Sets a newly value and return former value
|
void |
setIfAbsent(T value)
Sets a new value if former value is null
|
T |
setIfMatches(T value,
BiPredicate<T,T> predicate) |
T |
setIfMatches(T value,
Predicate<T> predicate) |
T |
setIfPresent(T value)
Replaces value if former value is not null,
and return former value
|
String |
toString() |
public static <T> Holder<T> empty()
public static <T> Holder<T> of(T value)
public boolean isEmpty()
true then the value is nullpublic T set(T value)
value - the newly valuepublic void setIfAbsent(T value)
value - the new valuepublic T setIfPresent(T value)
value - the newly valuepublic T setIfMatches(T value, BiPredicate<T,T> predicate)
public T get()
public <E extends Throwable> T orElseThrow(Supplier<? extends E> exceptionSupplier) throws E extends Throwable
E extends ThrowableCopyright © 2023. All rights reserved.