History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEA-11689
Type: New Feature New Feature
Status: Open Open
Assignee: Alexey Kudravtsev
Reporter: chad pratt
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
IDEA: Feedback

Collection aware getter / setter proposal for code-->generate getter setter menu item

Created: 23 Feb 07 21:43   Updated: 15 Aug 07 17:38
Component/s: Editor. Code Completion

Environment: win64 pro
Issue Links:
Duplicate
 
This issue is duplicated by:
IDEA-14289 Advanced setter and getter methods. Resolved

Build: 6,656


 Description  « Hide
I would rather have put this under "code generation", but I did not see that as a category.

CURRENT STATE OF AFFAIRS:
Currently under the menu code-->generate selecting the getter/setter will present fields to generate getter /setters for; the generation is ignorant about what kind of field is involved.

PROPOSED IMPROVEMENT:
It would be valuable and have a high "wow" factor if , when generate-->getter setter was applied to a Map, the getter wrote a function that took an instance of the key, and returned an instance of the value, for parameterized Collection types.

COMMENT:
This is probably what the user wants anyway, since rarely are whole Collections are rarely exposed outside of the class.

Thanks and let me know if I am posting suggestions to the wrong place.



 All   Comments   Work Log   Change History      Sort Order:
Vladislav Kaznacheev - 26 Feb 07 17:46
This is definitely the right place for that kind of suggestions.
Thanks.

Peter Lawrey - 15 Aug 07 17:38
In IDEA-14289 I suggest this could be extended to any interface, not just collections. This could done by select which methods you want to expose for a give field and the method names could be a combination of the method name and the field name.

An example would be direct support for concurrency wrappers AtomicBoolean, AtomicInteger, AtomicLong, AtomicReference.

e.g.
class MyType {
final AtomicLong counter = new AtomicLong(0L);

// the following is generated.
// the parameter name is taken from AtomicLong.set(long newValue)
public void setCounter(long newValue) { counter.set(newValue); }

public long getCounter() { return counter.get(); }

public long getAndAddCounter(long delta) { return counter.getAndAdd(delta); }