Skip to content
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

Limit Visitor to a Particaular type #14

Open
bghost4 opened this issue Mar 9, 2018 · 5 comments
Open

Limit Visitor to a Particaular type #14

bghost4 opened this issue Mar 9, 2018 · 5 comments

Comments

@bghost4
Copy link

bghost4 commented Mar 9, 2018

is there a way to limit the visitor to a particular type?
I saw an IncludeType command line arg, but that doesn't take any arguments itself.

For example if you had something that contained a list of substitutionGroup it would be nice to have the visitor work on just that substitution group. not for every type in the schema.

@bghost4
Copy link
Author

bghost4 commented Mar 9, 2018

After looking through the code base, I'd like to add some more info.
possibly just add visitors for SubstuituionGroups or Choice.

The work you have done on this is awesome. Keep up the good work.

@massfords
Copy link
Owner

I think the includeType was a patch because some schemas have a massive amount of methods and in one case a user reported a problem with too many overloaded methods all named "visit". This param will instead generate methods with the prefix of visit plus the type name.

If you provide a test case for the substitution groups then I could have a look. I need to better understand the requirement. Perhaps specifying a filter via xpath or similar might work.

@massfords
Copy link
Owner

massfords commented Jul 27, 2022

Revisiting this after updating the code a little.

The current behavior is to generate a single Visitor interface with a visit method for each concrete bean.

I can see adding some options to the plugin to further restrict the classes that we visit (and also traverse). I believe this could be done by simply filtering the outline that the plugin is given to remove any classes that we discover that shouldn't be included.

I'm not sure how this filter would be expressed. If the schemas are large or external like the OGC schemas then it's possible that there isn't a naming convention so a filter based on the fully qualified name isn't suitable.

The OGC schemas also aren't well suited to this use case since their schemas result in a generic class for operations like BinaryComparisonOpType that has a property indicating the type of the operation. This repeats for other types in that schema as well. This isn't as useful as having top level classes to visit for separate operation types since each visit implementation effectively has to test the operation name to know what to do.

I think with a cleaner set of schemas, it could be possible to have the filter include only concrete types that are referenced from some base type via an XmlSeeAlso or similar. It's also worth considering if this option emits multiple visitors, one for each group of related types.

@Warpten
Copy link

Warpten commented Jul 13, 2023

I've implemented this in a local copy; I added -Xvisitor-subtypesOf-exact:... and -XVisitor-subtypesOf:.... Both can be repeated and will match on types whose name (partially) match any of the provided value, or that of any of the types they inherit/implement. Just some food for thought; I can share the implementation if interested.

@massfords
Copy link
Owner

@Warpten feel free to create a PR or drop a link to your implementation.

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

No branches or pull requests

3 participants