Fluent Builder

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Fluent Builder

me2stk
Hello everyone,

I have the follwoing case:

Class A {

    public void setField(String field){



}
Reply | Threaded
Open this post in threaded view
|

Re: Fluent Builder

me2stk
Sorry for the incomplete entry, I occasionally clicked enter on the wrong context.

I have the follwoing case (in a fluent builder):

Class A {
    String field;


    public A field(String field){
       this.field = field;
       return A;
    }

    public void setField(String field){
       this.field = field;
    }
}


A a = new A();
a.field("value")

I intend to use the field() method, but it seems that the inferencing engine concludes that the setter is is being used instead. This breaks the fluent builder.

Cheers,
Mitko
Reply | Threaded
Open this post in threaded view
|

Re: Fluent Builder

René Scheibe
Hi Mitko,

you should use [hidden email] for Groovy questions. I set the
F'up accordingly.

It looks like you haven't posted the code you are using. Itt contains
some quirks:

1) 'Class A' -> 'class A'
2) 'return A' -> 'return this'

But it works as intended. Calling the field() method returns the object.

a.setField('test')
=> null

a.field('test')
=> A@20b40ec4

a.field = 'test'
=> test

Regards,
René Scheibe

On 07/05/2011 11:04 AM, me2stk wrote:

> Sorry for the incomplete entry, I occasionally clicked enter on the
> wrong context.
>
> I have the follwoing case (in a fluent builder):
>
> Class A {
>     String field;
>
>
>     public A field(String field){
>        this.field = field;
>        return A;
>     }
>
>     public void setField(String field){
>        this.field = field;
>     }
> }
>
>
> A a = new A();
> a.field("value")
>
> I intend to use the field() method, but it seems that the inferencing
> engine concludes that the setter is is being used instead. This breaks
> the fluent builder.
>
> Cheers,
> Mitko


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Fluent Builder

me2stk
Hi Rene,

Thanks for the answer.

The bytecode that is generated by the Groovy compiler is O.K. The field() method is called correctly as you noticed - so it is not a Groovy issue.
The actual problem is that the code after the a.field(). method is "underlined" (sorry for the incomplete description). This means "non understood" by the plugin - the type info is lost. It seems that the plugin infers the type wrongly.


Regards,
Mitko


On Tue, Jul 5, 2011 at 12:22 PM, René Scheibe <[hidden email]> wrote:
Hi Mitko,

you should use [hidden email] for Groovy questions. I set the
F'up accordingly.

It looks like you haven't posted the code you are using. Itt contains
some quirks:

1) 'Class A' -> 'class A'
2) 'return A' -> 'return this'

But it works as intended. Calling the field() method returns the object.

a.setField('test')
=> null

a.field('test')
=> A@20b40ec4

a.field = 'test'
=> test

Regards,
René Scheibe

On 07/05/2011 11:04 AM, me2stk wrote:
> Sorry for the incomplete entry, I occasionally clicked enter on the
> wrong context.
>
> I have the follwoing case (in a fluent builder):
>
> Class A {
>     String field;
>
>
>     public A field(String field){
>        this.field = field;
>        return A;
>     }
>
>     public void setField(String field){
>        this.field = field;
>     }
> }
>
>
> A a = new A();
> a.field("value")
>
> I intend to use the field() method, but it seems that the inferencing
> engine concludes that the setter is is being used instead. This breaks
> the fluent builder.
>
> Cheers,
> Mitko


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Fluent Builder

Andy Clement
Hi,

Please raise a jira for it at http://jira.codehaus.org/browse/GRECLIPSE

> I intend to use the field() method, but it seems that the inferencing engine concludes that the setter is is being used instead.

Actually it is inferring that a (generated) getter is being used,
returning a result of type String, so 'a.field("value").charAt(3)'
does not have charAt underlined. (and it then fails at runtime with
charAt not being defined for A)

cheers
Andy

On 5 July 2011 04:19, me2stk <[hidden email]> wrote:

> Hi Rene,
>
> Thanks for the answer.
>
> The bytecode that is generated by the Groovy compiler is O.K. The field()
> method is called correctly as you noticed - so it is not a Groovy issue.
> The actual problem is that the code after the a.field(). method is
> "underlined" (sorry for the incomplete description). This means "non
> understood" by the plugin - the type info is lost. It seems that the plugin
> infers the type wrongly.
>
>
> Regards,
> Mitko
>
>
> On Tue, Jul 5, 2011 at 12:22 PM, René Scheibe <[hidden email]>
> wrote:
>>
>> Hi Mitko,
>>
>> you should use [hidden email] for Groovy questions. I set the
>> F'up accordingly.
>>
>> It looks like you haven't posted the code you are using. Itt contains
>> some quirks:
>>
>> 1) 'Class A' -> 'class A'
>> 2) 'return A' -> 'return this'
>>
>> But it works as intended. Calling the field() method returns the object.
>>
>> a.setField('test')
>> => null
>>
>> a.field('test')
>> => A@20b40ec4
>>
>> a.field = 'test'
>> => test
>>
>> Regards,
>> René Scheibe
>>
>> On 07/05/2011 11:04 AM, me2stk wrote:
>> > Sorry for the incomplete entry, I occasionally clicked enter on the
>> > wrong context.
>> >
>> > I have the follwoing case (in a fluent builder):
>> >
>> > Class A {
>> >     String field;
>> >
>> >
>> >     public A field(String field){
>> >        this.field = field;
>> >        return A;
>> >     }
>> >
>> >     public void setField(String field){
>> >        this.field = field;
>> >     }
>> > }
>> >
>> >
>> > A a = new A();
>> > a.field("value")
>> >
>> > I intend to use the field() method, but it seems that the inferencing
>> > engine concludes that the setter is is being used instead. This breaks
>> > the fluent builder.
>> >
>> > Cheers,
>> > Mitko
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Fluent Builder

me2stk
Hi Andy,

Yes, you are right, the getter seems to be inferred. The issue is already there:
http://jira.codehaus.org/browse/GRECLIPSE-1105

Cheers,
Mitko


On Tue, Jul 5, 2011 at 5:06 PM, Andy Clement <[hidden email]> wrote:
Hi,

Please raise a jira for it at http://jira.codehaus.org/browse/GRECLIPSE

> I intend to use the field() method, but it seems that the inferencing engine concludes that the setter is is being used instead.

Actually it is inferring that a (generated) getter is being used,
returning a result of type String, so 'a.field("value").charAt(3)'
does not have charAt underlined. (and it then fails at runtime with
charAt not being defined for A)

cheers
Andy

On 5 July 2011 04:19, me2stk <[hidden email]> wrote:
> Hi Rene,
>
> Thanks for the answer.
>
> The bytecode that is generated by the Groovy compiler is O.K. The field()
> method is called correctly as you noticed - so it is not a Groovy issue.
> The actual problem is that the code after the a.field(). method is
> "underlined" (sorry for the incomplete description). This means "non
> understood" by the plugin - the type info is lost. It seems that the plugin
> infers the type wrongly.
>
>
> Regards,
> Mitko
>
>
> On Tue, Jul 5, 2011 at 12:22 PM, René Scheibe <[hidden email]>
> wrote:
>>
>> Hi Mitko,
>>
>> you should use [hidden email] for Groovy questions. I set the
>> F'up accordingly.
>>
>> It looks like you haven't posted the code you are using. Itt contains
>> some quirks:
>>
>> 1) 'Class A' -> 'class A'
>> 2) 'return A' -> 'return this'
>>
>> But it works as intended. Calling the field() method returns the object.
>>
>> a.setField('test')
>> => null
>>
>> a.field('test')
>> => A@20b40ec4
>>
>> a.field = 'test'
>> => test
>>
>> Regards,
>> René Scheibe
>>
>> On 07/05/2011 11:04 AM, me2stk wrote:
>> > Sorry for the incomplete entry, I occasionally clicked enter on the
>> > wrong context.
>> >
>> > I have the follwoing case (in a fluent builder):
>> >
>> > Class A {
>> >     String field;
>> >
>> >
>> >     public A field(String field){
>> >        this.field = field;
>> >        return A;
>> >     }
>> >
>> >     public void setField(String field){
>> >        this.field = field;
>> >     }
>> > }
>> >
>> >
>> > A a = new A();
>> > a.field("value")
>> >
>> > I intend to use the field() method, but it seems that the inferencing
>> > engine concludes that the setter is is being used instead. This breaks
>> > the fluent builder.
>> >
>> > Cheers,
>> > Mitko
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email