Skip to content

Instantly share code, notes, and snippets.

@eiryu
Created July 3, 2015 06:34
Show Gist options
  • Save eiryu/a4f134d76ddd6e13e5f2 to your computer and use it in GitHub Desktop.
Save eiryu/a4f134d76ddd6e13e5f2 to your computer and use it in GitHub Desktop.
org.apache.commons.beanutils.PropertyUtils
@Grab('commons-beanutils:commons-beanutils:1.8.3')
import org.apache.commons.beanutils.PropertyUtils
def b= new Bean();
b.name= 'bob'
b.age= 11
println b
// Mapに詰めてくれる
Map<String, Object> m= PropertyUtils.describe(b)
println m
class Bean {
String name
int age
public String toString() {
return "name="+ name+ ", age="+age
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment