Created
November 5, 2011 08:30
Revisions
-
Y. Kanamura revised this gist
Nov 5, 2011 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,8 +39,7 @@ def params = [ contact :"090-3321-3213" ] assert map2Map(defaultMap,params) == [ familyName :"郷田", givenName :"武", zipcode :"176-0002", -
Y. Kanamura revised this gist
Nov 5, 2011 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ def map2Map(defaultMap,map){ } def defaultMap = [ familyName :{lastName}, givenName :{firstName}, zipcode :{"${location.zip1}-${location.zip2}"}, address1 :{"${location.pref}${location.city}"}, @@ -25,10 +25,10 @@ def params = [ firstName :"武", lastName :"郷田", email :"gian@example.jp", mobileEmail :"gian-takeshi@example-mobile.com", sex :"male", birthday :"1964/6/15", location :[ zip1 :"176", zip2 :"0002", pref :"東京都", @@ -41,7 +41,7 @@ def params = [ def newMap = map2Map(defaultMap,params) assert newMap == [ familyName :"郷田", givenName :"武", zipcode :"176-0002", address1 :"東京都練馬区", -
Y. Kanamura created this gist
Nov 5, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ def map2Map(defaultMap,map){ def resultMap = [:] defaultMap.each{k,v -> if(v instanceof Map){ resultMap[k] = map2Map(v,map) }else if(v instanceof Closure){ resultMap[k] = map.with(v) } } return resultMap } def defaultMap = [ familyName:{lastName}, givenName :{firstName}, zipcode :{"${location.zip1}-${location.zip2}"}, address1 :{"${location.pref}${location.city}"}, address2 :{"${location.address}${location.building}"}, male :{sex=="male"} ] def params = [ userid :2341, password :"9b2FG530", firstName :"武", lastName :"郷田", email :"gian@example.jp", mobileEmail:"gian-takeshi@example-mobile.com", sex :"male", birthday :"1964/6/15", location:[ zip1 :"176", zip2 :"0002", pref :"東京都", city :"練馬区", address :"月見台すすきヶ原3-3-1", building :"", ], contact :"090-3321-3213" ] def newMap = map2Map(defaultMap,params) assert newMap == [ familyName:"郷田", givenName :"武", zipcode :"176-0002", address1 :"東京都練馬区", address2 :"月見台すすきヶ原3-3-1", male :true ]