Interface DefaultingStrategy
- All Known Subinterfaces:
CompositeConfigurationStrategy.CompositeDefaultingStrategy
A defaulting strategy is used in a DefaultableConfigurationSource
to implement defaulting configuration mechanism.
A defaulting strategy derives a list of queries from an original query whose order specifies result priorities. The source shall retain the first non-empty result from that list or the empty result if no result is returned for any of the queries returned by the strategy.
- Since:
- 1.5
- Author:
- Jeremy Kuhn
-
Method Summary
Modifier and TypeMethodDescriptiongetDefaultingKeys
(ConfigurationKey queryKey) Derives a list of queries from the specified original query.getListDefaultingKeys
(ConfigurationKey queryKey) Derives a list of keys that defines the set of properties that must be retained in a list query.static DefaultingStrategy
lookup()
Returns a lookup defaulting strategy.static DefaultingStrategy
noOp()
Returns a NoOp defaulting strategy.static DefaultingStrategy
wildcard()
Returns a wildcard defaulting strategy.
-
Method Details
-
noOp
Returns a NoOp defaulting strategy.
The NoOp defaulting strategy does not support defaulting and simply returns the original query.
- Returns:
- a NoOp defaulting strategy
-
lookup
Returns a lookup defaulting strategy.
A lookup defaulting strategy support defaulting by prioritizing parameters from left to right: the best matching property is the one matching the most continuous parameters from left to right.
If we consider query key
property[p1=v1,...pn=vn]
, it supersedes keyproperty[p1=v1,...pn-1=vn-1]
which supersedes keyproperty[p1=v1,...pn-2=vn-2]
... which supersedes keyproperty[]
. It basically tells the source to lookup by successively removing the rightmost parameter if no exact result exists for a particular query.As a result, an original query with
n
parameters results inn+1
potential queries to execute for the source. The query result is then the first non-empty result or the empty result.The order into which parameters are defined in the original query is then significant:
property[p1=v1,p2=v2] != property[p2=v2,p1=v1]
.When listing properties, this strategy includes the parent properties which are obtained by successively removing the rightmost parameter from the original query.
- Returns:
- a lookup defaulting strategy
-
wildcard
Returns a wildcard defaulting strategy.
If we consider query key
property[p1=v1,...pn=vn]
, the most precise result is the one defining parameters[p1=v1,...pn=vn]
, it supersedes results that definen-1
query parameters, which supersedes results that definen-2
query parameters... which supersedes results that define no query parameters. Conflicts may arise when a source defines a property with different set of query parameters with the same cardinality (e.g. when it defines propertiesproperty[p1=v1,p2=v2]
andproperty[p1=v1,p3=v3]
). In such situation, priority is always given to parameters from left to right (thereforeproperty[p1=v1,p2=v2]
supersedesproperty[p1=v1,p3=v3]
)An original query with
n
parameters then results in2^n
potential queries to execute for the source (the sum of the k-combinations from 0 to n). The query result is the first non-empty result or the empty result.The order into which parameters are defined in the original query is then significant:
property[p1=v1,p2=v2] != property[p2=v2,p1=v1]
.When listing properties, this strategy includes all properties that could match the query parameters.
- Returns:
- a wildcard defaulting strategy
-
getDefaultingKeys
Derives a list of queries from the specified original query.
The order of the returned queries must determine the result priorities. The source must consider queries in that order to determine the best matching result for the original query.
- Parameters:
queryKey
- the original query- Returns:
- a list of configuration queries
-
getListDefaultingKeys
Derives a list of keys that defines the set of properties that must be retained in a list query.
A source shall use these keys to determine whether a given property must be included in the results of a list query.
Note that in case of a
ListConfigurationQuery.executeAll()
operation, the source shall only include properties with extra parameters that only match the first key so as to exclude properties inconsistent with the orignal query.- Parameters:
queryKey
- the original query- Returns:
- a list of configuration keys
-