@PublicSpi
public interface EffectProvider
effect
descriptions
to pieces of runnable code
.Modifier and Type | Method and Description |
---|---|
default List<StoredEffect> |
optimize(List<StoredEffect> effects)
Attempts to reduce effect application time by optimizing the given effects collection.
|
EffectResponse |
resolve(StoredEffect effect)
Converts an effect description to an actual effect implementation,
if possible.
|
@NotNull EffectResponse resolve(@NotNull StoredEffect effect)
Converts an effect description to an actual effect implementation, if possible.
This method performs all the checks required to make sure that the effect succeeds, e.g. it checks that all referenced entities do exist, and that the current user has sufficient permissions to change them.
If the change cannot be performed, returns an error response explaining the problem.
@NotNull default List<StoredEffect> optimize(@NotNull List<StoredEffect> effects)
Attempts to reduce effect application time by optimizing the given effects collection. Optimization examples are removing duplicates and resolving conflicts. A conflict is a situation when an effect overrides a previous effect. Conflicts and duplicates may occur when there are duplicate items in the forest or several effectors produce similar effects. The effect provider is not required to optimize all the situations but may attempt to speed up effect application by removing effects or joining several effects into one. When resolving a conflict between several effects the last one should be considered dominant. No other restrictions are imposed here. The method may add new effects and warnings, and nevertheless the results of its work are considered an optimization.
The method may be called after all effectors in the effector process have generated effects. There is no guarantee this method will be called at all, because there are situations that clearly do not require optimization.
The default implementation returns the source list unchanged (no optimization).
effects
- list of effects belonging (by module key) to this EffectProvider, in creation orderCopyright © 2024 Tempo Software. All Rights Reserved.