[ 
https://issues.apache.org/jira/browse/GROOVY-7809?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Donny updated GROOVY-7809:
--------------------------
    Summary: Create a map from selected properties of an Object  (was: Create a 
map from an Object's selected properties )

> Create a map from selected properties of an Object
> --------------------------------------------------
>
>                 Key: GROOVY-7809
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7809
>             Project: Groovy
>          Issue Type: New Feature
>          Components: syntax
>            Reporter: Donny
>            Priority: Minor
>
> It would be nice if Groovy allows developers to create a map from selected 
> properties of an Object
> Below are the example:
> {code:title=Example|theme=FadeToGrey|linenumbers=true|language=groovy|firstline=0001|collapse=false}
> 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']
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to