Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
T |
get()
Return the object that was bound or throw a
NoSuchElementException if no
value was bound. |
int |
hashCode() |
void |
ifBound(Consumer<? super T> consumer)
Invoke the specified consumer with the bound value, or do nothing if no value has
been bound.
|
boolean |
isBound()
Returns
true if a result was bound. |
<U> BindResult<U> |
map(Function<? super T,? extends U> mapper)
Apply the provided mapping function to the bound value, or return an updated
unbound result if no value has been bound.
|
T |
orElse(T other)
Return the object that was bound, or
other if no value has been bound. |
T |
orElseCreate(Class<? extends T> type)
Deprecated.
since 2.2.0 in favor of
Binder.bindOrCreate(java.lang.String, java.lang.Class<T>) |
T |
orElseGet(Supplier<? extends T> other)
Return the object that was bound, or the result of invoking
other if no
value has been bound. |
<X extends Throwable> |
orElseThrow(Supplier<? extends X> exceptionSupplier)
Return the object that was bound, or throw an exception to be created by the
provided supplier if no value has been bound.
|
public T get() throws NoSuchElementException
NoSuchElementException
if no
value was bound.null
)NoSuchElementException
- if no value was boundisBound()
public boolean isBound()
true
if a result was bound.public void ifBound(Consumer<? super T> consumer)
consumer
- block to execute if a value has been boundpublic <U> BindResult<U> map(Function<? super T,? extends U> mapper)
U
- the type of the result of the mapping functionmapper
- a mapping function to apply to the bound value. The mapper will not
be invoked if no value has been bound.BindResult
describing the result of applying a mapping function
to the value of this BindResult
.public T orElse(T other)
other
if no value has been bound.other
- the value to be returned if there is no bound value (may be
null
)other
public T orElseGet(Supplier<? extends T> other)
other
if no
value has been bound.other
- a Supplier
of the value to be returned if there is no bound
valueother
@Deprecated public T orElseCreate(Class<? extends T> type)
Binder.bindOrCreate(java.lang.String, java.lang.Class<T>)
type
- the type to create if no value was boundtype
public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X extends Throwable
X
- the type of the exception to be thrownexceptionSupplier
- the supplier which will return the exception to be thrownX
- if there is no value presentX extends Throwable
Copyright © 2021 Pivotal Software, Inc.. All rights reserved.