ilmoeuro / snakeyaml

Automatically exported from code.google.com/p/snakeyaml
0 stars 0 forks source link

Sorting of fields in the dump() output #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is only a suggestion, not a bug. It would be very nice if we had an
option to not sort the fields, but just print it in the order it appears in
the Java Class. It's more readable that way.

Keep up the good work!

Ashwin.

Original issue reported on code.google.com by ashwin.j...@gmail.com on 18 Sep 2009 at 10:34

GoogleCodeExporter commented 9 years ago
Do you mean Java class or Java source ?
When the class is compiled the order from the source is lost. Java runtime does 
not 
provide a way to keep the order of instance variables.

Original comment by py4fun@gmail.com on 19 Sep 2009 at 8:14

GoogleCodeExporter commented 9 years ago
Explicit ordering would be possible - Annotate fields with a user defined 
number and
then sort it. But that would be asking for too much ;-)

Cheers!

Original comment by ashwin.j...@gmail.com on 20 Sep 2009 at 7:16

GoogleCodeExporter commented 9 years ago
I do not think field sorting is important enough to be implemented in 
SnakeYAML. 
Imagine the class extends another class. Imagine the child _overwrites_ some 
fields. 
I am afraid if you ask 10 developers how it shall be sorted you will get 10 
different opinions.
If you think the order may be very important then indeed we may consider to use 
annotations.

Original comment by py4fun@gmail.com on 20 Sep 2009 at 10:44

GoogleCodeExporter commented 9 years ago
We shall collect more input from the user community.

Original comment by aso...@gmail.com on 24 Sep 2009 at 3:30