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

Return JType from SchemaMapper.generate(...) #137

Closed
ddossot opened this issue Dec 16, 2013 · 2 comments
Closed

Return JType from SchemaMapper.generate(...) #137

ddossot opened this issue Dec 16, 2013 · 2 comments
Milestone

Comments

@ddossot
Copy link

ddossot commented Dec 16, 2013

It's hard to know beforehand what will be the exact Java class name that is created by SchemaMapper.generate(...) so it would be very convenient if the JType created by:

ruleFactory.getSchemaRule().apply(className, schemaNode, jpackage, new Schema(null, schemaNode));

could be returned.

@joelittlejohn
Copy link
Owner

A schema can ultimately cause many types to be generated. Would you be happy to just get the top-most type then traverse the available fields to find out about other types? It might be nicer if we return something like Set<JType>.

One way that I think you could work around this right now is by using a stateful custom annotator that simply stores the JDefinedClass every time a call to say propertyOrder(JDefinedClass,JsonNode) is made. The annotator could build a Set<JType> value and you could grab this after the call to generate has completed.

@ddossot
Copy link
Author

ddossot commented Dec 16, 2013

In my particular case - a generator for RAML http://raml.org/ - the top most class would be enough, but I understand that it's not generic enough, since many types can be created. The problem with a set is that it won't be possible to easily find out the top-most one, unless it's a sorted set and the order is based on the depth of the generated type.

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

No branches or pull requests

2 participants