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
ConstructorsModifierConstructorDescriptionprotectedprotectedAbstractProvider(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 aValuemade up of the relevant return values.final TypeReturns aTyperepresenting 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 aTyperepresenting the lower bound of all possible values supplied by thisAbstractProvider.- Specified by:
lowerBoundin interfaceProvider- Returns:
- the lower type bound of this
AbstractProviderimplementation, ornullif 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 aValuemade up of the relevant return values.- Specified by:
getin interfaceProvider- Parameters:
requestor- theLoaderseeking aValue; must not benullabsolutePath- an absolutePathfor which the suppliedLoaderis seeking a value; must not benull- Returns:
- a
Valuemore or less suitable for the combination of the suppliedLoaderandPath, ornullif there is no suchValuenow and if there never will be such aValuefor the supplied arguments - Throws:
NullPointerException- if eitherrequestororabsolutePathisnullIllegalArgumentException- ifabsolutePathis 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 aSuppliersuitable for the suppliedLoaderandPath, ornullif there is no suchSuppliernow and if there never will be such aSupplierfor 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- theLoaderseeking aValue(as originally passed to theget(Loader, Path)method); must not benullabsolutePath- an absolutePathfor which the suppliedLoaderis seeking a value (as originally passed to theget(Loader, Path)method); must not benull- Returns:
- a
Suppliermore or less suitable for the combination of the suppliedLoaderandPath, ornullif there is no suchSuppliernow and if there never will be such aSupplierfor the supplied arguments - Throws:
NullPointerException- if eitherrequestororabsolutePathisnullIllegalArgumentException- ifabsolutePathis 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 returnnullas 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 aPaththat will be used to build aValueto 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-nullvalue.- Type Parameters:
T- the type of both the supplied and returnedPaths- Parameters:
requestor- requestor theLoaderseeking aValue(as originally passed to theget(Loader, Path)method); must not benullabsolutePath- an absolutePathfor which the suppliedLoaderis seeking a value (as originally passed to theget(Loader, Path)method); must not benull- Returns:
- a
Paththat will be used to build aValueto be returned by theget(Loader, Path)method; ifnull, then theget(Loader, Path)method will returnnullas well - Throws:
NullPointerException- if eitherrequestororabsolutePathisnullIllegalArgumentException- ifabsolutePathis 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.
-