public interface ContextCalculator<T extends Contextual>
Contexts applicable for a
Implementations of this interface should satisfy the following requirements:
Calculators should be registered with the corresponding
Context lookups for instances provided by the platform,
Player) are delegated to the active
Plugins wishing to provide contexts for these instances should register
When the provider of a
ContextualService changes, calculators must
be registered again. Plugins should listen to the
ChangeServiceProviderEvent to ensure their calculators are registered
with any replacement providers.
|Modifier and Type||Method and Description|
Creates a new
static <T extends Contextual> ContextCalculator<T> forSingleContext(String key, Function<T,String> valueFunction)
ContextCalculatorthat provides a single context.
T- The contextual type
key- The key of the context provided by the calculator
valueFunction- The function used to compute the corresponding value for each query. A context will not be "accumulated" if the value returned is null.
Contexts this calculator determines to be applicable to the
Care should be taken to ensure implementations of this method meet the
general requirements for
ContextCalculator, defined in the class
Calculators should not rely on the state of
this call, and also shouldn't make calls to remove contexts added by
Contextis currently applicable to a
If this calculator does not handle the given type of context, this method should return false.
For the given set of contexts which would be accumulated using
accumulateContexts(Contextual, Set), this method should return
true if the given context would be included in the accumulated set.