Bug 334822 - [templates] Add Java editor template variables to iterate over class fields
Summary: [templates] Add Java editor template variables to iterate over class fields
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P5 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 436580 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-01-19 14:15 EST by JW CLA
Modified: 2023-01-26 02:45 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description JW CLA 2011-01-19 14:15:51 EST
Build Identifier: 20100917-0705

If this exists, I would welcome a pointer to some clear documentation.  I will describe my need in the hopes that will clarify what I am looking for.  I need to perform repeat operations on all fields of the class I'm in.  For example:

public void printAll() {
  int count = 0;
  System.out.println("Variable " + pos++ + ":" + ${field variable here});
  ... etc.
}

Note that this is a simple example.  I am aware of the automatic "toString()" functionality, but that is not what I'm after.  I used this example for simplicity.

This would also be useful in writing a different custom equals than what Eclipse provides.

Reproducible: Always
Comment 1 Olivier Thomann CLA 2011-01-19 14:17:32 EST
Move to JDT/UI
Comment 2 Dani Megert CLA 2014-10-21 04:07:05 EDT
*** Bug 436580 has been marked as a duplicate of this bug. ***
Comment 3 Juergen Weber CLA 2023-01-26 02:45:00 EST
This would be very useful for filling DTOs.

Syntax could be s.th. along

${field-foreach} public void myFancySetter(${field-type} ${field-name}) .....