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
ConstructorsConstructorDescriptionCreates a newEnvironmentVariableProviderthat uses flat keys.EnvironmentVariableProvider(boolean flatKeys) Creates a newEnvironmentVariableProvider. -
Method Summary
Modifier and TypeMethodDescriptionprotected Supplier<?>If the suppliedabsolutePathhas a size of2(the root plus a single name), returns a deterministicSupplierwhoseSupplier.get()method returns the environment variable with that name, ornullin all other cases.protected static final StringOverrides theAbstractProvider.path(Loader, Path)method to return a (relative)Pathconsisting 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 newEnvironmentVariableProviderthat 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 suppliedabsolutePathhas a size of2(the root plus a single name), returns a deterministicSupplierwhoseSupplier.get()method returns the environment variable with that name, ornullin all other cases.- Specified by:
findin classAbstractProvider- Parameters:
requestor- theLoaderrequesting aValue; must not benullabsolutePath- an absolutePath; must not benull- Returns:
- a deterministic
SupplierwhoseSupplier.get()method returns the appropriate environment variable if the suppliedabsolutePathhas a size of2(the root plus a single name) and there actually is a corresponding environment variable;nullin all other cases - Throws:
NullPointerException- ifrequestororabsolutePathisnull- 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)Pathconsisting solely of the last element of the suppliedabsolutePath.- Overrides:
pathin classAbstractProvider- Type Parameters:
T- the type of both the supplied and returnedPaths- Parameters:
requestor- theLoaderseeking aValue; must not benullabsolutePath- an absolutePathfor which aValueis being sought; must not benull- Returns:
- a
Paththat will be used to build aValueto 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- thePathin question; must not benullflat- whether the key is derived from the suppliedPath's last element's name only- Returns:
- a
Stringrepresentation of 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.
-