Bug 334822

Summary: [templates] Add Java editor template variables to iterate over class fields
Product: [Eclipse Project] JDT Reporter: JW <jw2online>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P5 CC: daniel_megert, juergen, Olivier_Thomann, vuk
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

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}) .....