[ 
https://issues.apache.org/jira/browse/COMMONSRDF-49?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16365054#comment-16365054
 ] 

ASF GitHub Bot commented on COMMONSRDF-49:
------------------------------------------

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..


> Make AbstractRDFParser serializable
> -----------------------------------
>
>                 Key: COMMONSRDF-49
>                 URL: https://issues.apache.org/jira/browse/COMMONSRDF-49
>             Project: Apache Commons RDF
>          Issue Type: New Feature
>          Components: simple
>    Affects Versions: 0.3.0
>            Reporter: Stian Soiland-Reyes
>            Assignee: Stian Soiland-Reyes
>            Priority: Major
>              Labels: parser
>             Fix For: 0.6.0
>
>
> Raised by [~p_ansell] in [pull request 
> 25|(https://github.com/apache/incubator-commonsrdf/pull/25#discussion_r85436754]
> {quote}
> The use of optional here as a field type makes it impossible to serialise. 
> Need to have the raw values stored in fields if you want to support 
> serialisation in the future, which should otherwise be possible.
> {quote}
> The suggestion is to avoid {{Optional}} in the private fields of 
> {{AbstractRDFParser}} so it can be serialized - it can still be {{Optional}} 
> in the accessor methods.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to