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
Follow-up from PR #110 review: #110 (comment) (johanfylling).
Context
AnnotationIntrospector(inopa-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: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:
Scope / notes
opa-evaluator(the SPI +DefaultAnnotationIntrospector) and theopa-jacksonimplementation, plus the mapper call sites.