java.lang.Object
org.microbean.loader.spi.Value<T>
- Type Parameters:
T- the type of value thisValuereturns
- 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 Paths for which it might be
suitable.
Values 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns an appropriateOptionalSupplier.Determinismfor thisValue.final booleanfinal Tget()Invokes theget()method of theSuppliersupplied at construction time and returns its value, which may benull.final inthashCode()path()final Qualifiers<? extends String,?> Returns theQualifierswith which thisValueis associated.final Typetype()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, waitMethods 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 thisValueis suitable; must not benull- Throws:
NullPointerException- ifpathisnull- See Also:
-
Value
- Parameters:
path- thePath, possibly relative, for which thisValueis suitable; must not benullvalue- a fixed value to be returned by theget()method whenever it is invoked; may benull- Throws:
NullPointerException- ifpathisnull- See Also:
-
Value
Creates a newValue.- Parameters:
source- theValueto use as the primary supplier; must not benulldefaults- theSupplierto use as the fallback; may benull- Throws:
NullPointerException- ifsourceisnull
-
Value
Creates a newValue.- Parameters:
supplier- the actualSupplierthat will return values; may benullpath- thePath, possibly relative, for which thisValueis suitable; must not benull- Throws:
NullPointerException- ifpathisnull
-
-
Method Details
-
with
- Parameters:
path- the newPath; must not benull- Returns:
- a
Valuewith thisValue's supplier and the suppliedPath - Throws:
NullPointerException- ifpathisnull- 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 theQualifierswith which thisValueis associated.- Returns:
- the
Qualifierswith which thisValueis 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 theSuppliersupplied at construction time and returns its value, which may benull.- Specified by:
getin interfaceOptionalSupplier<T>- Specified by:
getin interfaceSupplier<T>- Returns:
- tbe return value of an invocation of the
get()method of theSuppliersupplied 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
Suppliersupplied at construction time. - Nullability:
- This method may return
null. - Thread Safety:
- This method is safe for concurrent use by multiple
threads, provided that the
Suppliersupplied at construction time is also safe for concurrent use by multiple threads.
-
determinism
Returns an appropriateOptionalSupplier.Determinismfor thisValue.- Specified by:
determinismin interfaceOptionalSupplier<T>- Returns:
- an appropriate
OptionalSupplier.Determinismfor 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
Returnstrueif thisValueis equal to the suppliedObject.This method will return
trueif and only if the following conditions hold:- The supplied
Objectis notnull - The supplied
Object'sObject.getClass()method returnsValue.class Objects.equals(this.path(), otherValue.path())returnstrueObjects.equals(this.determinism(), otherValue.determinism())returnstrue
- Overrides:
equalsin classObject- Parameters:
other- theObjectto test; may benullin which casefalsewill be returned- Returns:
trueif thisValueis equal to the suppliedObject;falseotherwise- See Also:
- Idempotency:
- This method is idempotent and and deterministic.
- Thread Safety:
- This method is safe for concurrent use by multiple threads.
- The supplied
-