java.lang.Object
org.microbean.loader.spi.AbstractProvider
org.microbean.loader.EnvironmentVariableProvider
- All Implemented Interfaces:
Provider
An
AbstractProvider
that provides access to environment variables.- Author:
- Laird Nelson
-
Constructor Summary
ConstructorDescriptionCreates a newEnvironmentVariableProvider
that uses flat keys.EnvironmentVariableProvider
(boolean flatKeys) Creates a newEnvironmentVariableProvider
. -
Method Summary
Modifier and TypeMethodDescriptionprotected Supplier<?>
If the suppliedabsolutePath
has a size of2
(the root plus a single name), returns a deterministicSupplier
whoseSupplier.get()
method returns the environment variable with that name, ornull
in all other cases.protected static final String
Overrides theAbstractProvider.path(Loader, Path)
method to return a (relative)Path
consisting solely of the last element of the suppliedabsolutePath
.Methods inherited from class org.microbean.loader.spi.AbstractProvider
get, lowerBound
-
Constructor Details
-
EnvironmentVariableProvider
public EnvironmentVariableProvider()Creates a newEnvironmentVariableProvider
that uses flat keys.- See Also:
-
EnvironmentVariableProvider
Creates a newEnvironmentVariableProvider
.- Parameters:
flatKeys
- whether the key for an environment variable is derived from aPath
's last element's name only
-
-
Method Details
-
find
If the suppliedabsolutePath
has a size of2
(the root plus a single name), returns a deterministicSupplier
whoseSupplier.get()
method returns the environment variable with that name, ornull
in all other cases.- Specified by:
find
in classAbstractProvider
- Parameters:
requestor
- theLoader
requesting aValue
; must not benull
absolutePath
- an absolutePath
; must not benull
- Returns:
- a deterministic
Supplier
whoseSupplier.get()
method returns the appropriate environment variable if the suppliedabsolutePath
has a size of2
(the root plus a single name) and there actually is a corresponding environment variable;null
in all other cases - Throws:
NullPointerException
- ifrequestor
orabsolutePath
isnull
- See Also:
- Idempotency:
- This method is idempotent and deterministic during the lifetime of a Java virtual machine instance.
- Nullability:
- This method may return
null
. - Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
path
Overrides theAbstractProvider.path(Loader, Path)
method to return a (relative)Path
consisting solely of the last element of the suppliedabsolutePath
.- Overrides:
path
in classAbstractProvider
- Type Parameters:
T
- the type of both the supplied and returnedPath
s- Parameters:
requestor
- theLoader
seeking aValue
; must not benull
absolutePath
- an absolutePath
for which aValue
is being sought; must not benull
- Returns:
- a
Path
that will be used to build aValue
to be returned by theAbstractProvider.get(Loader, Path)
method - See Also:
- Idempotency:
- This method is, and its overrides must be, idempotent and deterministic.
- Nullability:
- This method does not, but overrides may, return
null
. - Thread Safety:
- This method is, and its overrides must be, safe for concurrent use by multiple threads.
-
key
- Parameters:
path
- thePath
in question; must not benull
flat
- whether the key is derived from the suppliedPath
's last element's name only- Returns:
- a
String
representation of 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.
-