Skip to content

Simplify the AnnotationIntrospector SPI: return a ClassInfo instead of many per-element queries #178

Description

@sspaink

Follow-up from PR #110 review: #110 (comment) (johanfylling).

Context

AnnotationIntrospector (in opa-evaluator, io.github.open_policy_agent.opa.mapper) is the SPI the mapper consults to resolve annotation-driven property metadata without binding the evaluator to a specific JSON library. Today it exposes many fine-grained "ask a question" methods:

String findPropertyName(Method getter, Field backingField);
boolean isIgnored(Method getter, Field backingField);
boolean isNonNullInclude(Method getter, Field backingField);
String findCreatorParamName(Parameter param);
boolean isJsonCreator(Constructor<?> ctor);
boolean isJsonCreator(Method method);
Visibility findFieldVisibility(Class<?> clazz);
boolean isJsonValue(Method method);

Proposal

As suggested in review, consider inverting the shape: instead of the mapper asking the introspector a series of questions per element, give the introspector a Class<?> and have it hand back a resolved descriptor (e.g. ClassInfo) that carries the property names, ignored set, null-inclusion, creator info, visibility, and JSON-value method in one pass.

Potential benefits:

  • Simpler SPI surface (one entry point instead of eight).
  • Implementations can resolve a class once rather than being re-queried per getter/field/parameter.
  • Clearer contract for the null-argument combinations that the current per-element methods have to document.

Scope / notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions