Enum Class AopEligibility.Rule

java.lang.Object
java.lang.Enum<AopEligibility.Rule>
com.ultikits.ultitools.aop.AopEligibility.Rule
All Implemented Interfaces:
Serializable, Comparable<AopEligibility.Rule>, java.lang.constant.Constable
Enclosing class:
AopEligibility

private static enum AopEligibility.Rule extends Enum<AopEligibility.Rule>
The five proxy-eligibility rules, unified per D-36.

AopEligibility.check(Class, Set) and AopEligibility.isProxyable(Method, Class) used to restate these five conditions as two separately maintained if/else if chains, kept in sync only by a javadoc sentence asking a human to remember. Each constant here supplies both halves - violates(Method, Class) and describe(Method, Class) - as abstract members, so a sixth rule fails to compile until both exist. That is what replaces the sentence.

The two halves have deliberately different costs. violates does no string work at all and is safe to call once per method per bean on the startup path. describe builds the remediation text by concatenation and is called only when violates already returned true, and only from AopEligibility.check(java.lang.Class<?>, java.util.Set<java.lang.reflect.Method>)'s reporting path - never from AopEligibility.isProxyable(java.lang.reflect.Method, java.lang.Class<?>), which is the boolean query. Issue #317's literal proposal, a single method returning a AopEligibility.Problem with isProxyable defined as that result being absent, is rejected for exactly this reason: it would build and discard every rule's diagnostic text on every boolean call. See issue #309.

Enum order is the previous chain's order, and AopEligibility.check(java.lang.Class<?>, java.util.Set<java.lang.reflect.Method>) and AopEligibility.isProxyable(java.lang.reflect.Method, java.lang.Class<?>) both stop at the first violated rule - preserving the old chain's else-if semantics, where only one problem is ever reported per method.

  • Enum Constant Details

    • STATIC_METHOD

      public static final AopEligibility.Rule STATIC_METHOD
      Static methods are dispatched with invokestatic, which bypasses the proxy.
    • PRIVATE_METHOD

      public static final AopEligibility.Rule PRIVATE_METHOD
      Private methods are dispatched with invokespecial, which bypasses the proxy.
    • FINAL_METHOD

      public static final AopEligibility.Rule FINAL_METHOD
      Final methods cannot be overridden, so the proxy cannot intercept them.
    • INACCESSIBLE_METHOD

      public static final AopEligibility.Rule INACCESSIBLE_METHOD
      Package-private and declared in a different package than the bean - relative to the bean class, not intrinsic to the method.
    • SHADOWED_METHOD

      public static final AopEligibility.Rule SHADOWED_METHOD
      Hidden by a nearer declaration - usually the bridge method a generic override generates - also relative to the bean class.
  • Field Details

  • Constructor Details

  • Method Details

    • values

      public static AopEligibility.Rule[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static AopEligibility.Rule valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • violates

      abstract boolean violates(Method method, Class<?> beanClass)
      Cheap, string-free predicate. Safe to call once per method per bean on the startup path.
      Parameters:
      method - the annotated method
      beanClass - the class the proxy would extend
      Returns:
      true if this method violates this rule
    • describeViolation

      abstract String describeViolation(Method method, Class<?> beanClass)
      Builds this rule's remediation text. Only ever called after violates(java.lang.reflect.Method, java.lang.Class<?>) already returned true for the same arguments.
      Parameters:
      method - the annotated method
      beanClass - the class the proxy would extend
      Returns:
      actionable instructions for the module author
    • describe

      final String describe(Method method, Class<?> beanClass)
      Builds this rule's remediation text and records that it did so.

      The only caller is AopEligibility.check(Class, Set)'s reporting path; AopEligibility.isProxyable(java.lang.reflect.Method, java.lang.Class<?>) must never reach this method. AopEligibility.DESCRIBE_CALLS is what lets a test prove that directly rather than only by reading the method body.