Class ConditionEvaluator

java.lang.Object
com.zetaplugins.zetacore.di.condition.ConditionEvaluator

public class ConditionEvaluator extends Object
Evaluates Conditional, ConditionalOnPlugin and ConditionalOnMissingPlugin on classes and methods. The result of each Condition class is cached. The evaluator is thread-safe.
  • Constructor Details

    • ConditionEvaluator

      public ConditionEvaluator(JavaPlugin plugin, ServiceRegistry registry)
      Creates an evaluator.
      Parameters:
      plugin - The plugin, used to look up other plugins.
      registry - The registry used to create conditions with dependency injection, or null to create them with their no-argument constructor.
  • Method Details

    • matches

      public boolean matches(AnnotatedElement element)
      Checks whether all conditions on the element match. Elements without conditions always match.
      Parameters:
      element - The class or method to check.
      Returns:
      True if the element is active.
    • findFailedCondition

      public String findFailedCondition(AnnotatedElement element)
      Finds the first condition on the element that does not match.
      Parameters:
      element - The class or method to check.
      Returns:
      A description of the failed condition, or null if all conditions match.