java.lang.Object
org.microbean.loader.spi.Value<T>
- Type Parameters:
T
- the type of value thisValue
returns
- All Implemented Interfaces:
Supplier<T>
,OptionalSupplier<T>
An
OptionalSupplier
of a value that is additionally
qualified by a Path
partially identifying the kinds of
Qualifiers
and Path
s for which it might be
suitable.
Value
s are typically returned by Provider
implementations.
A Value
once received retains no reference to whatever
produced it and can be regarded as an authoritative source for
(possibly ever-changing) values going forward. Notably, it can be
cached.
- Author:
- Laird Nelson
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.microbean.invoke.OptionalSupplier
OptionalSupplier.Determinism
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns an appropriateOptionalSupplier.Determinism
for thisValue
.final boolean
final T
get()
Invokes theget()
method of theSupplier
supplied at construction time and returns its value, which may benull
.final int
hashCode()
path()
final Qualifiers<? extends String,
?> Returns theQualifiers
with which thisValue
is associated.final Type
type()
Returns the type erasure of the return value of thetype()
method.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.microbean.invoke.OptionalSupplier
exceptionally, handle, ifPresent, ifPresentOrElse, optional, optional, optional, orElse, orElseGet, orElseThrow, orElseThrow, stream
-
Constructor Details
-
Value
- Parameters:
path
- thePath
, possibly relative, for which thisValue
is suitable; must not benull
- Throws:
NullPointerException
- ifpath
isnull
- See Also:
-
Value
- Parameters:
path
- thePath
, possibly relative, for which thisValue
is suitable; must not benull
value
- a fixed value to be returned by theget()
method whenever it is invoked; may benull
- Throws:
NullPointerException
- ifpath
isnull
- See Also:
-
Value
Creates a newValue
.- Parameters:
source
- theValue
to use as the primary supplier; must not benull
defaults
- theSupplier
to use as the fallback; may benull
- Throws:
NullPointerException
- ifsource
isnull
-
Value
Creates a newValue
.- Parameters:
supplier
- the actualSupplier
that will return values; may benull
path
- thePath
, possibly relative, for which thisValue
is suitable; must not benull
- Throws:
NullPointerException
- ifpath
isnull
-
-
Method Details
-
with
- Parameters:
path
- the newPath
; must not benull
- Returns:
- a
Value
with thisValue
's supplier and the suppliedPath
- Throws:
NullPointerException
- ifpath
isnull
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
qualifiers
Returns theQualifiers
with which thisValue
is associated.- Returns:
- the
Qualifiers
with which thisValue
is associated - See Also:
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
path
-
get
Invokes theget()
method of theSupplier
supplied at construction time and returns its value, which may benull
.- Specified by:
get
in interfaceOptionalSupplier<T>
- Specified by:
get
in interfaceSupplier<T>
- Returns:
- tbe return value of an invocation of the
get()
method of theSupplier
supplied at construction time, which may benull
- Throws:
NoSuchElementException
- if this method should no longer be invoked because there is no chance it will ever produce a suitable value againUnsupportedOperationException
- if this method should no longer be invoked because there is no chance it will ever produce a suitable value again- See Also:
- Idempotency:
- This method is as idempotent and deterministic as
the
Supplier
supplied at construction time. - Nullability:
- This method may return
null
. - Thread Safety:
- This method is safe for concurrent use by multiple
threads, provided that the
Supplier
supplied at construction time is also safe for concurrent use by multiple threads.
-
determinism
Returns an appropriateOptionalSupplier.Determinism
for thisValue
.- Specified by:
determinism
in interfaceOptionalSupplier<T>
- Returns:
- an appropriate
OptionalSupplier.Determinism
for thisValue
- Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
type
Returns the result of invokingPath.qualified()
on the return value of thisValue
'spath()
method.This method never returns
null
.- Returns:
- the result of invoking
Path.qualified()
on the return value of thisValue
'spath()
method; nevernull
- See Also:
- Idempotency:
- This method is idempotent and and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
typeErasure
Returns the type erasure of the return value of thetype()
method.This method never returns
null
.- Returns:
- the result of invoking
JavaTypes.erase(Type)
on the return value of thisValue
'stype()
method; nevernull
- Throws:
IllegalStateException
- if somehow the return value oftype()
could not be erased- See Also:
-
path()
JavaTypes.erase(Type)
- Idempotency:
- This method is idempotent and and deterministic.
- Nullability:
- This method never returns
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
hashCode
-
equals
Returnstrue
if thisValue
is equal to the suppliedObject
.This method will return
true
if and only if the following conditions hold:- The supplied
Object
is notnull
- The supplied
Object
'sObject.getClass()
method returnsValue.class
Objects.equals(this.path(), otherValue.path())
returnstrue
Objects.equals(this.determinism(), otherValue.determinism())
returnstrue
- Overrides:
equals
in classObject
- Parameters:
other
- theObject
to test; may benull
in which casefalse
will be returned- Returns:
true
if thisValue
is equal to the suppliedObject
;false
otherwise- See Also:
- Idempotency:
- This method is idempotent and and deterministic.
- Thread Safety:
- This method is safe for concurrent use by multiple threads.
- The supplied
-