Skip to content

Reflective structures #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open

Reflective structures #4

wants to merge 28 commits into from

Conversation

lukebemish
Copy link
Member

@lukebemish lukebemish commented Mar 3, 2025

Adds an API for constructing structures reflectively from a class. For instance:

public record TestRecord(int a, String b, TestEnum c) {
    public static final Structure<TestRecord> STRUCTURE = ReflectiveStructureCreator.create(TestRecord.class);
}

public enum TestEnum {
    A,
    B,
    C
}

TODO:

  • Add support for annotations from gson/others
  • Support optional/nullable fields
  • Add annotations specific for structures, such a pointing a given field at a particular structure.
  • Add annotations for comments and the like
  • Look into groovy support, including retrieving groovydoc
  • Self referencing classes
  • Caching (probably relevant to self referencing classes)
  • Add recursive structure support to remaining interpreters, with tests
  • Write docs
  • Make tests more comprehensive
  • Handle reified generic records
  • Allow contextual specification of method handles and test in modular environment

@lukebemish
Copy link
Member Author

lukebemish commented Mar 4, 2025

Recursion is going to be something that may take a bit -- turns out normal Structures don't support it in all cases at present. Got structures to support them, and then just propogated that system to the reflective system.

@lukebemish
Copy link
Member Author

Turns out commented codecs broke at some point, and I discovered while writing tests for reflective structures with comments! Well, this is what we have tests for -- added some more for commented codecs in particular.

@lukebemish
Copy link
Member Author

Groovy groovydoc detection and use is supported through a small class that bounces to an implementation at present -- is this my favorite? No. It only works if groovy is visible from codecextras's classloader -- which in different-module-layer cases might not, I suppose, be the case. This may be expanded if I ever end up making a specific codecextras-groovy module -- I'll just move it there as a service implementer.

@lukebemish
Copy link
Member Author

Also working on mutable data representation for structures -- which adds a few more renames/refactors for the next time I do BCs. Not sure if there's a sensible way to hook those up reflectively, and I may not bother -- the proper API there is almost certainly direct use of DataElements and types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant