noctarius / borabora

borabora is a CBOR (cbor.io) parser supporting graph queries and lazy decoding of stream elements
Apache License 2.0
13 stars 5 forks source link

Provide better Builder API support for Semantic Tags #21

Closed noctarius closed 8 years ago

noctarius commented 8 years ago

Semantic tags can have complex data items like sequences or maps. A simple approach like ValueBuilder#putTag(Object value) or ValueBuilder#putValue(Object value) doesn't always work in this place. ValueBuilder#put(Value(Object value) supplied with a java.util.List or an array would encode into a CBOR sequence. Anyhow it may that the expected result should have been different in this case, therefore a more clear API is necessary.

Current idea involves a ValueBuilder#putTag(Class<? extends SemanticTagBuilder> builderClass) overload to provide a more sophisticated API based on the Semantic Tag implementor.

noctarius commented 8 years ago

Final DSL API turned out to be:

graphBuilder.putTag(
    semanticTag(DateTimeBuilder.class).putDateTime(expected).endSemanticTag()
).finishStream();