public abstract class AbstractResourceLoadingConfiguration<T> extends AbstractConfiguration implements Ranked
AbstractConfiguration
that flexibly loads some kind of
resource, or uses a previously loaded one, to satisfy demands for
configuration property values.Modifier and Type | Class and Description |
---|---|
static class |
AbstractResourceLoadingConfiguration.Resource<T>
A
Supplier of a particular kind of resource from which
configuration property values may be retrieved. |
Modifier | Constructor and Description |
---|---|
protected |
AbstractResourceLoadingConfiguration(Function<? super Map<? extends String,? extends String>,? extends AbstractResourceLoadingConfiguration.Resource<? extends T>> resourceLoader)
Creates a new
AbstractResourceLoadingConfiguration . |
Modifier and Type | Method and Description |
---|---|
Set<String> |
getNames()
|
protected abstract Set<String> |
getNames(AbstractResourceLoadingConfiguration.Resource<? extends T> resource) |
int |
getRank() |
protected int |
getRank(AbstractResourceLoadingConfiguration.Resource<? extends T> resource) |
protected abstract ConfigurationValue |
getValue(AbstractResourceLoadingConfiguration.Resource<? extends T> resource,
Map<String,String> requestedCoordinates,
String name)
Returns a
ConfigurationValue suitable for the supplied
name normally sourced in some fashion from the supplied
AbstractResourceLoadingConfiguration.Resource , or null if no such ConfigurationValue can be found. |
ConfigurationValue |
getValue(Map<String,String> coordinates,
String name)
Returns a
ConfigurationValue suitable for the supplied
configurationCoordinates and name , or null if there is no suitable value. |
getConfigurations, setConfigurations
protected AbstractResourceLoadingConfiguration(Function<? super Map<? extends String,? extends String>,? extends AbstractResourceLoadingConfiguration.Resource<? extends T>> resourceLoader)
AbstractResourceLoadingConfiguration
.resourceLoader
- a Function
that accepts a Map
of requested configuration coordinates and returns a AbstractResourceLoadingConfiguration.Resource
that can supply a source of
configuration values for use by the getValue(Resource,
Map, String)
method; may be null
in which case all
invocations of the getValue(Map, String)
method will
return null
getValue(Resource, Map, String)
,
getValue(Map, String)
,
AbstractResourceLoadingConfiguration.Resource
protected int getRank(AbstractResourceLoadingConfiguration.Resource<? extends T> resource)
public ConfigurationValue getValue(Map<String,String> coordinates, String name)
ConfigurationValue
suitable for the supplied
configurationCoordinates
and name
, or null
if there is no suitable value.
Implementations of this method may return null
.
The ConfigurationValue
that is returned must
have a name that is
equal to the supplied name
.
The ConfigurationValue
that is returned must be
created with this Configuration
as the first parameter value supplied to its
constructor.
The ConfigurationValue
that is returned must be
created with a set of configuration
coordinates that is a subset of the supplied configurationCoordinates
.
This implementation calls the getValue(Resource, Map,
String)
method with the return value resulting from the
invocation of the Function
supplied at construction
time.
getValue
in interface Configuration
coordinates
- the requested configuration coordinates; may be null
name
- the name of a configuration property for which a
value should be returned; must not be null
ConfigurationValue
suitable for the supplied
configurationCoordinates
and name
, or null
NullPointerException
- if name
is null
getValue(Resource, Map, String)
public Set<String> getNames()
Configuration
Set
of the names of all ConfigurationValue
s that might be returned by this Configuration
.
Implementations of this method must not return null
.
Just because a name appears in the returned Set
does
not mean that a ConfigurationValue
will be
returned for it in a location in configuration space identified
by any arbitrary set of configuration coordinates.
getNames
in interface Configuration
null
Set
of namesprotected abstract ConfigurationValue getValue(AbstractResourceLoadingConfiguration.Resource<? extends T> resource, Map<String,String> requestedCoordinates, String name)
ConfigurationValue
suitable for the supplied
name
normally sourced in some fashion from the supplied
AbstractResourceLoadingConfiguration.Resource
, or null
if no such ConfigurationValue
can be found.
Implementations of this method are permitted to return null
.
Implementations of this method must not call the getValue(Map, String)
method or undefined behavior will
result.
resource
- a AbstractResourceLoadingConfiguration.Resource
hopefully providing access to
the ultimate source of configuration values for the requested
coordinates; must not be null
requestedCoordinates
- for convenience, the same Map
supplied to the getValue(Map, String)
method is supplied
here representing the configuration coordinates for which a value
is requested; note that these may very well be different from
the configuration
coordinates actually pertaining to the resource; most
implementations will not need to reference this parametername
- the name of the configuration property for which a
value is to be sought; must not be null
ConfigurationValue
or null
NullPointerException
- if resource
or name
is null
getValue(Map, String)
,
AbstractResourceLoadingConfiguration.Resource
protected abstract Set<String> getNames(AbstractResourceLoadingConfiguration.Resource<? extends T> resource)
Copyright © 2017–2019, microBean. All rights reserved.