You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by Adam Jacobs <ja...@hotmail.com> on 2017/11/17 15:55:43 UTC

Generic RDFVisitor

I wonder if it would be useful to generify the `RDFVisitor` interface...

public interface RDFVisitor<B,U,L> {

    B visitBlank( Resource r, AnonId id );
    U visitURI( Resource r, String uri );
    L visitLiteral( Literal l );

}

Re: Generic RDFVisitor

Posted by Adam Jacobs <ja...@hotmail.com>.
I don't actually have a use case for the generics. I just saw that the interface was implemented in a pre-Java 5 style and wondered if it would help to modernize it, without breaking backwards compatibility of course. If the interface isn't used much, that probably answers my question.   :)



________________________________________
From: ajs6f <aj...@apache.org>
Sent: Friday, November 17, 2017 11:03 AM
To: dev@jena.apache.org
Subject: Re: Generic RDFVisitor

Perhaps you can say a little more about your use case here? I think we could probably work something out for this feature, but I am curious about why you are reaching for the visitor pattern?

ajs6f

> On Nov 17, 2017, at 11:27 AM, Adam Jacobs <ja...@hotmail.com> wrote:
>
> Perhaps only a single generic parameter then, if each method should return the same type.
> Or a sub-interface in which all three parameters are the same, the way that Java's `UnaryOperator` is related to `Function`.
>
>
> ________________________________________
> From: ajs6f <aj...@apache.org>
> Sent: Friday, November 17, 2017 10:01 AM
> To: dev@jena.apache.org
> Subject: Re: Generic RDFVisitor
>
> Not sure how that would play against:
>
> Object org.apache.jena.rdf.model.impl.ResourceImpl.visitWith(RDFVisitor)
>
> OTOH, I'm not sure how much use the visitor pattern there has ever really gotten...
>
> ajs6f
>
>> On Nov 17, 2017, at 10:55 AM, Adam Jacobs <ja...@hotmail.com> wrote:
>>
>> I wonder if it would be useful to generify the `RDFVisitor` interface...
>>
>> public interface RDFVisitor<B,U,L> {
>>
>>   B visitBlank( Resource r, AnonId id );
>>   U visitURI( Resource r, String uri );
>>   L visitLiteral( Literal l );
>>
>> }
>


Re: Generic RDFVisitor

Posted by ajs6f <aj...@apache.org>.
Perhaps you can say a little more about your use case here? I think we could probably work something out for this feature, but I am curious about why you are reaching for the visitor pattern?

ajs6f

> On Nov 17, 2017, at 11:27 AM, Adam Jacobs <ja...@hotmail.com> wrote:
> 
> Perhaps only a single generic parameter then, if each method should return the same type.
> Or a sub-interface in which all three parameters are the same, the way that Java's `UnaryOperator` is related to `Function`.
> 
> 
> ________________________________________
> From: ajs6f <aj...@apache.org>
> Sent: Friday, November 17, 2017 10:01 AM
> To: dev@jena.apache.org
> Subject: Re: Generic RDFVisitor
> 
> Not sure how that would play against:
> 
> Object org.apache.jena.rdf.model.impl.ResourceImpl.visitWith(RDFVisitor)
> 
> OTOH, I'm not sure how much use the visitor pattern there has ever really gotten...
> 
> ajs6f
> 
>> On Nov 17, 2017, at 10:55 AM, Adam Jacobs <ja...@hotmail.com> wrote:
>> 
>> I wonder if it would be useful to generify the `RDFVisitor` interface...
>> 
>> public interface RDFVisitor<B,U,L> {
>> 
>>   B visitBlank( Resource r, AnonId id );
>>   U visitURI( Resource r, String uri );
>>   L visitLiteral( Literal l );
>> 
>> }
> 


Re: Generic RDFVisitor

Posted by Adam Jacobs <ja...@hotmail.com>.
Perhaps only a single generic parameter then, if each method should return the same type.
Or a sub-interface in which all three parameters are the same, the way that Java's `UnaryOperator` is related to `Function`.


________________________________________
From: ajs6f <aj...@apache.org>
Sent: Friday, November 17, 2017 10:01 AM
To: dev@jena.apache.org
Subject: Re: Generic RDFVisitor

Not sure how that would play against:

Object org.apache.jena.rdf.model.impl.ResourceImpl.visitWith(RDFVisitor)

OTOH, I'm not sure how much use the visitor pattern there has ever really gotten...

ajs6f

> On Nov 17, 2017, at 10:55 AM, Adam Jacobs <ja...@hotmail.com> wrote:
>
> I wonder if it would be useful to generify the `RDFVisitor` interface...
>
> public interface RDFVisitor<B,U,L> {
>
>    B visitBlank( Resource r, AnonId id );
>    U visitURI( Resource r, String uri );
>    L visitLiteral( Literal l );
>
> }


Re: Generic RDFVisitor

Posted by ajs6f <aj...@apache.org>.
Not sure how that would play against:

Object org.apache.jena.rdf.model.impl.ResourceImpl.visitWith(RDFVisitor)

OTOH, I'm not sure how much use the visitor pattern there has ever really gotten...

ajs6f

> On Nov 17, 2017, at 10:55 AM, Adam Jacobs <ja...@hotmail.com> wrote:
> 
> I wonder if it would be useful to generify the `RDFVisitor` interface...
> 
> public interface RDFVisitor<B,U,L> {
> 
>    B visitBlank( Resource r, AnonId id );
>    U visitURI( Resource r, String uri );
>    L visitLiteral( Literal l );
> 
> }