java.lang.Object
org.microbean.loader.spi.AbstractProvider
- All Implemented Interfaces:
Provider
- Direct Known Subclasses:
AbstractTreeBasedProvider
,EnvironmentVariableProvider
,ProxyingProvider
,SystemPropertyProvider
A skeletal
Provider
implementation.- Author:
- Laird Nelson
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
protected
AbstractProvider
(Type lowerBound) Creates a newAbstractProvider
. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Supplier<?>
final Value<?>
Implements theProvider.get(Loader, Path)
method to first call thefind(Loader, Path)
method, and, if necessary, thepath(Loader, Path)
method, and to then return aValue
made up of the relevant return values.final Type
Returns aType
representing the lower bound of all possible values supplied by thisAbstractProvider
.
-
Constructor Details
-
AbstractProvider
protected AbstractProvider()- See Also:
-
AbstractProvider
Creates a newAbstractProvider
.- Parameters:
lowerBound
- the lower type bound of thisAbstractProvider
; may be, and often is,null
- See Also:
-
-
Method Details
-
lowerBound
Returns aType
representing the lower bound of all possible values supplied by thisAbstractProvider
.- Specified by:
lowerBound
in interfaceProvider
- Returns:
- the lower type bound of this
AbstractProvider
implementation, ornull
if its lower bound is the lowest possible bound - Idempotency:
- This method is idempotent and deterministic.
- Nullability:
- This method may return
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
get
Implements theProvider.get(Loader, Path)
method to first call thefind(Loader, Path)
method, and, if necessary, thepath(Loader, Path)
method, and to then return aValue
made up of the relevant return values.- Specified by:
get
in interfaceProvider
- Parameters:
requestor
- theLoader
seeking aValue
; must not benull
absolutePath
- an absolutePath
for which the suppliedLoader
is seeking a value; must not benull
- Returns:
- a
Value
more or less suitable for the combination of the suppliedLoader
andPath
, ornull
if there is no suchValue
now and if there never will be such aValue
for the supplied arguments - Throws:
NullPointerException
- if eitherrequestor
orabsolutePath
isnull
IllegalArgumentException
- ifabsolutePath
is not absolute, or if!absolutePath.startsWith(requestor.absolutePath())
, or ifabsolutePath.equals(requestor.absolutePath())
- See Also:
- Idempotency:
- This method is idempotent, but not necessarily deterministic.
- Nullability:
- This method may return
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
find
Returns aSupplier
suitable for the suppliedLoader
andPath
, ornull
if there is no suchSupplier
now and if there never will be such aSupplier
for the supplied arguments.Overrides of this method must not call the
get(Loader, Path)
method or undefined behavior (such as an infinite loop) may result.- Parameters:
requestor
- theLoader
seeking aValue
(as originally passed to theget(Loader, Path)
method); must not benull
absolutePath
- an absolutePath
for which the suppliedLoader
is seeking a value (as originally passed to theget(Loader, Path)
method); must not benull
- Returns:
- a
Supplier
more or less suitable for the combination of the suppliedLoader
andPath
, ornull
if there is no suchSupplier
now and if there never will be such aSupplier
for the supplied arguments - Throws:
NullPointerException
- if eitherrequestor
orabsolutePath
isnull
IllegalArgumentException
- ifabsolutePath
is not absolute, or if!absolutePath.startsWith(requestor.absolutePath())
, or ifabsolutePath.equals(requestor.absolutePath())
- See Also:
- Idempotency:
- Overrides of this method must be idempotent but are not assumed to be deterministic.
- Nullability:
- Overrides of this method may return
null
, in which case theget(Loader, Path)
method will returnnull
as well. - Thread Safety:
- Overrides of this method must be safe for concurrent use by multiple threads.
-
path
@OverridingEncouraged protected <T extends Type> Path<T> path(Loader<?> requestor, Path<T> absolutePath) Returns aPath
that will be used to build aValue
to be returned by theget(Loader, Path)
method.This method does not, and its overrides must not, call the
get(Loader, Path)
method or undefined behavior (such as an infinite loop) may result.The default implementation of this method returns the supplied
absolutePath
.This method is called by the
get(Loader, Path)
method only when a call to thefind(Loader, Path)
method returns a non-null
value.- Type Parameters:
T
- the type of both the supplied and returnedPath
s- Parameters:
requestor
- requestor theLoader
seeking aValue
(as originally passed to theget(Loader, Path)
method); must not benull
absolutePath
- an absolutePath
for which the suppliedLoader
is seeking a value (as originally passed to theget(Loader, Path)
method); must not benull
- Returns:
- a
Path
that will be used to build aValue
to be returned by theget(Loader, Path)
method; ifnull
, then theget(Loader, Path)
method will returnnull
as well - Throws:
NullPointerException
- if eitherrequestor
orabsolutePath
isnull
IllegalArgumentException
- ifabsolutePath
is not absolute, or if!absolutePath.startsWith(requestor.absolutePath())
, or ifabsolutePath.equals(requestor.absolutePath())
- See Also:
- Idempotency:
- This method is, and its overrides must be, idempotent and deterministic.
- Nullability:
- This method does not, but its overrides may, return
null
. - Thread Safety:
- This method is, and its overrides must be, safe for concurrent use by multiple threads.
-