[
https://issues.apache.org/jira/browse/AVRO-1274?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tom White updated AVRO-1274:
----------------------------
Attachment: AVRO-1274.patch
Thanks a lot for sharing that, Josh! I like the idea of making sure that things
that should be specified should be passed as method parameters in one go,
rather than through chaining, which makes it a lot harder to see what is
required. So I took the liberty of updating the patch to use
requiredX/optionalX methods like in your code. It's not quite finished, but
this shows the idea:
{code}
Schema schema = SchemaBuilder
.recordType("myrecord").aliases("oldrecord")
.requiredString("f0")
.requiredLong("f1").doc("This is f1")
.optionalBoolean("f2", true)
.build();
{code}
As this example shows, it is still possible to set things like doc and aliases
- it's just that you can ignore them if you like.
Regarding Doug's points...
> But perhaps the preferred import should instead be 'import static
> SchemaBuilder.*'? The static methods have unique-enough names that this might
> work well. What do you think?
Sounds good.
> We can convert from Java object to JsonNode by parsing the output of
> GenericData.toString(Object).
Thanks. I've updated the patch to do this, but it still needs tests for this
part.
> Add a schema builder API
> ------------------------
>
> Key: AVRO-1274
> URL: https://issues.apache.org/jira/browse/AVRO-1274
> Project: Avro
> Issue Type: New Feature
> Components: java
> Reporter: Tom White
> Assignee: Tom White
> Attachments: AVRO-1274.patch, AVRO-1274.patch
>
>
> It would be nice to have a fluent API that made it easier to construct record
> schemas.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira