Interface ContextService
-
public interface ContextService
A service that provides shared context calculation functionality for any services that may wish to use contexts.When functionality is provided to query data based upon a given
Set
ofContext
s, the querying code must consider which of the underlying data is "applicable" to the contexts specified in the query request. It is expected that implementations will deem entries of underlying data to be applicable if theSet
of contexts defined in the query contain all of theContext
s required by the data entry. Mathematically, an underlying data entry is "applicable" if [the context of the entry] is a subset of [the context provided in the query], or programmatically if [the context provided in the query]Set.containsAll(Collection)
of [the context of the entry].
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Set<Context>
contexts()
Get the active contexts from the current cause.Set<Context>
contextsFor(Cause cause)
Extract applicable contexts from the providedCause
.void
registerContextCalculator(ContextCalculator calculator)
Registers aContextCalculator
for use by this service.
-
-
-
Method Detail
-
contexts
Set<Context> contexts()
Get the active contexts from the current cause.- Returns:
- an immutable set of contexts
-
contextsFor
Set<Context> contextsFor(Cause cause)
Extract applicable contexts from the providedCause
.- Parameters:
cause
- source cause- Returns:
- immutable set of extracted contexts
-
registerContextCalculator
void registerContextCalculator(ContextCalculator calculator)
Registers aContextCalculator
for use by this service.- Parameters:
calculator
- The context calculator to register
-
-