Github user stain commented on the issue:

    https://github.com/apache/commons-rdf/pull/43
  
    Thanks, @ajs6f !
    
    I found some old code where I had tried to make a fluent interface.. I 
managed to update it to the current master and sorted some issues.
    
    I pushed it to the `fluent-parser` branch
    
    See https://github.com/apache/commons-rdf/compare/fluent-parser 
    
    I haven't implemented the `Parser` yet or written any tests.
    
    Basically the idea is this:
    
    ```java
          Parsed<Dataset, IRI> p = rdf.parserBuilder()
                                      .syntax(RDFSyntax.JSONLD)
                                      .source("http://example.com/data.jsonld";)
                                      .parse();
    ```
    
    or:
    
    ```java
    rdf.parserBuilder()
      .syntax(RDFSyntax.TURTLE)
      .target(quad -> System.out.println(quad.getSubject()))  
      .source(Paths.get("/tmp/file.ttl").
      .async().parseAsync();
    ```
    
    Now there is a set of interfaces, one for each step along the way, e.g. 
`NeedTarget`, and 
    some internal `_` package interfaces to ensure consistency (but this can be 
flattened). Note that it is easier in this code to explore this in Eclipse with 
auto-complete as the interfaces have not been flattened yet.
    
    It is implemented by a single `AbstractParserBuilder` which keeps all its 
state (except async executor) in a `ParserConfig` bean. The builder can be made 
immutable using `.build()` after which any change will make it mutable again.  
While it's mutable it will mutate the bean without any copies.
    
    There is also a more low-level `Parser` which takes a `ParserConfig` - this 
is basically how the RDF implementations can be invoked.
    
    I have not moved over the preflight checks in AbstractRDFParser there.
    
    Feel free to use it as a starting ground or inspiration! It's quite hard to 
do fluent interfaces..


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to