Search code examples
javaiderefactoringdtodto-mapping

Refactoring crazy inheritance hierarchies of value objects - How to get a list of all fields and types?


So basically, I need to manually adjust an inheritance hierarchy. I'd like for the classes to be perfect, no extra fields, and they're just DTO's. However, it's really easy to get lost and add duplicate fields, and it's really hard to see if what I'm looking for is already there. Something I'd really love to have is a way to list all the fields within a class, including its inherited fields (private too). Like a flattened field-only view with no getters and setters cluttering everything up.

I've found a way to show it in netbeans with right-click/File members, but I can't copy-paste and save it in a text file or anything.

Basically just these columns:

Name     Type            Superclass
id       int  
theDate  java.util.Date  com.something.AbstractDTO
...

Anyone know how to do it, or a better way to do what I'm trying to do?


Solution

  • If no pre-existing tool can be found it shouldn't be hard to write something that uses reflection to extract this information from your DTO classes. You'd need to recompile and re-run the program for updates, but that's better than nothing.