Package net.luckperms.api.context
Interface StaticContextCalculator
-
- All Superinterfaces:
ContextCalculator<Object>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface StaticContextCalculator extends ContextCalculator<Object>
Extension ofContextCalculatorwhich provides the same context regardless of the subject.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidcalculate(@NonNull Object target, @NonNull ContextConsumer consumer)Submits any contexts this calculator determines to be applicable to thetargetcontextual subject.voidcalculate(@NonNull ContextConsumer consumer)Submits any contexts this calculator determines to be applicable.static StaticContextCalculatorforSingleContext(String key, Supplier<String> valueFunction)Creates a newStaticContextCalculatorthat provides a single context.-
Methods inherited from interface net.luckperms.api.context.ContextCalculator
estimatePotentialContexts
-
-
-
-
Method Detail
-
forSingleContext
static StaticContextCalculator forSingleContext(String key, Supplier<String> valueFunction)
Creates a newStaticContextCalculatorthat provides a single context.- Parameters:
key- the key of the context provided by the calculatorvalueFunction- the function used to compute the corresponding value for each query. A context will not be "accumulated" if the value returned is null.- Returns:
- the resultant calculator
-
calculate
void calculate(@NonNull ContextConsumer consumer)
Submits any contexts this calculator determines to be applicable.Care should be taken to ensure implementations of this method meet the general requirements for
ContextCalculator, defined in the class doc.- Parameters:
consumer- theContextConsumerto submit contexts to
-
calculate
default void calculate(@NonNull Object target, @NonNull ContextConsumer consumer)
Description copied from interface:ContextCalculatorSubmits any contexts this calculator determines to be applicable to thetargetcontextual subject.Care should be taken to ensure implementations of this method meet the general requirements for
ContextCalculator, defined in the class doc.- Specified by:
calculatein interfaceContextCalculator<Object>- Parameters:
target- the target contextual subject for this operationconsumer- theContextConsumerto submit contexts to
-
-