Details
-
New Feature
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
It would be nice if Groovy allows developers to create a map from selected properties of an Object.
Below are the example:
Example
class Hero { String name Integer strength Integer constitution String weakness } Hero hero = new Hero(name: "Robin", strength: 70, constitution: 80, weakness: "Beautiful Women") def mapNoWeakness = hero.asMap(['name', 'strength', 'constitution']) println mapNoWeakness // [name: 'Robin', strength: 70, constitution: 80] def mapOnlyName = hero.asMap(['name']) println mapOnlyName // [name: 'Robin']