Bug 264912 - [getter setter] Source generator for getter/setter does not have option for "abstract"
Summary: [getter setter] Source generator for getter/setter does not have option for "...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4.1   Edit
Hardware: All All
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-13 17:56 EST by Charlie Kelly CLA
Modified: 2009-02-16 04:18 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Charlie Kelly CLA 2009-02-13 17:56:44 EST
Build ID: M20080911-1700

Steps To Reproduce:
The dialog for generating getter/setter method does not have an option for "abstract"


More information:
It would be helpful to have this option.

The template for the code would have a method signature, followed by a ";" and omit the method body.
Comment 1 Olivier Thomann CLA 2009-02-13 21:09:37 EST
Move to JDT/UI
Comment 2 Dani Megert CLA 2009-02-14 04:01:53 EST
Declaring a field and leave the getter/setter implementation to subclasses is a rare use case and in my personal opinion not a very good design. No plans to add this.
Comment 3 Charlie Kelly CLA 2009-02-14 10:55:30 EST
Dani's comment is correct for hand-written code.

The situation is different for modeled code.

Setter methods that include databinding and fire property changes can be tedious to write by hand.

Also, if fields in modeled class are annotated with JPA, some object relational mapping methodologies (for example, Hibernate) require the presence of getter/setter methods.  It is sufficient that these methods be abstract.
Comment 4 Dani Megert CLA 2009-02-15 11:58:54 EST
>The situation is different for modeled code.
Do you mean generated for a model?
Comment 5 Charlie Kelly CLA 2009-02-15 12:41:40 EST
(In reply to comment #4)
> >The situation is different for modeled code.
> Do you mean generated for a model?
> 
Hi Dani,

Yes.  The abstract getter/setter is contained in a model.

The generated code contains the method body.
The method body fires the property changes.
The generated class that contains the method defines the (generated) property that is associated with the property change.

These combine to provide support for databinding in the (generated) UI classes.
Comment 6 Dani Megert CLA 2009-02-16 03:24:32 EST
Looks like the previous two comments got lost by the infra server maintenance:


--- Comment #5 from CharlieKelly <Eclipse@CharlieKelly.com>  2009-02-15 12:41:40 -0400 ---
(In reply to comment #4)
> >The situation is different for modeled code.
> Do you mean generated for a model?
> 
Hi Dani,

Yes.  The abstract getter/setter is contained in a model.

The generated code contains the method body.
The method body fires the property changes.
The generated class that contains the method defines the (generated) property
that is associated with the property change.

These combine to provide support for databinding in the (generated) UI classes.
Comment 7 Dani Megert CLA 2009-02-16 03:26:05 EST
>The generated class that contains the method defines the (generated) property
>that is associated with the property change.
Good. If it generates the property and if it really needs the abstract methods then it should also generate those.
Comment 8 Charlie Kelly CLA 2009-02-16 03:57:48 EST
(In reply to comment #5)
> >The generated class that contains the method defines the (generated) property
> >that is associated with the property change.
> Good. If it generates the property and if it really needs the abstract methods
> then it should also generate those.
> 
Hibernate/JPA requires that they be in the model class (otherwise the model class cannot be included in the persistence hierarchy).



Comment 9 Dani Megert CLA 2009-02-16 04:03:40 EST
Yes, but don't you generate the model class?
Comment 10 Charlie Kelly CLA 2009-02-16 04:08:31 EST
(In reply to comment #7)
> Yes, but don't you generate the model class?
> 
No, the model class is written "by hand".
It is input to the generator
Comment 11 Dani Megert CLA 2009-02-16 04:18:22 EST
I see.