[
https://issues.apache.org/jira/browse/COMMONSRDF-11?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14490641#comment-14490641
]
Stian Soiland-Reyes (old) commented on COMMONSRDF-11:
-----------------------------------------------------
Let's say you need a Literal, and LiteralImpl does the job, except you want to
add a private field for the id it is stored as in a datastore, so you can
quickly match it up again.
Now you will have to create your totally own Literal with the same logic for
Types.RDF_LANGSTRING, languageTag.isEmpty() etc, or do some strange proxy (but
where your constructor has to use its own little SimpleRDFTermFactory just to
call the .createLiteral methods.
... or - we make LiteralImpl and its constructors public, and it can be re-used
even in a subclass.
When I made Simple I also intended it to be a "dead simple" POJO implementation
that could be used directly within for instance unit tests in other programs,
e.g. strawman:
{code}
IRI alice = new IRIImpl("http://example.com/alice");
Literal literal = new LiteralImpl("hello");
Triple t = someThirdParty.addGreeting(alice, literal);
assertEquals(new IRIImpl("http://example.com/greeting"), t.getPredicate());
{code}
This test code would get a bit side-tracked if you *have to* use a factory -
here we only need to make the Literal and IRI to test the addGreeting method -
when writing the test you know you need a Literal etc but might not have find
out all about commons-rdf to learn about the factory.
But I can buy into Peter's argument maintenance-wise, allowing simple to not
just be a black-box implementation would increase the burden on us and the
Commons later, specially if any of the big implementations directly subclass
some Simple that could mjean
> Simple should be extendable classes
> -----------------------------------
>
> Key: COMMONSRDF-11
> URL: https://issues.apache.org/jira/browse/COMMONSRDF-11
> Project: Apache Commons RDF
> Issue Type: Improvement
> Reporter: Stian Soiland-Reyes
> Assignee: Stian Soiland-Reyes
>
> In my view, org.apache.commons.rdf.simple should also be a possible basis for
> other implementations - for instance if they only need a new Graph and Triple
> implementation, they should be able to use the other classes directly.
> Current the simple classes are defined like:
> {code}
> final class LiteralImpl implements Literal {
> {code}
> with a mixture of public and package constructors.
> I would prefer for these to all be public, non-final, so that it would be
> easy to extend the simple* classes if so desired, and to instantiate them
> directly without having to make a shadow of SimpleRDFTermFactory.
> (Note - SimpleRDFTermFactory is not final and so can easily be subclassed to
> reuse some of the implementations, but constructors must be at least
> protected to be subclassable outside this package)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)