1

It is for Android, I know beanutils can do that but it doesn't work on Android.

Assume I have an java bean

class A
{
private int a;
public int getA() {
return a;
}
public int setA(int a) {
this.a = a;
}
}

what I want is:

A a= new A();
a.setA(1);

Map<string, object> m = somelibrary.translate(a);

and I'd like that m contains one key-value pair {"a", 1}

Renjith
  • 5,783
  • 9
  • 31
  • 42
juncai
  • 53
  • 1
  • 4
  • You could write one, using reflection. But Android doesn't use beans really. Why do you want to use one? – Gabe Sechan Aug 01 '13 at 04:01
  • [This answer](http://stackoverflow.com/a/12902658/180100)? –  Aug 01 '13 at 04:58
  • I'm sorry, I don't know the answer, but can you explain to me why you need something like this? – dierre Aug 01 '13 at 05:00
  • BTW I just realized that Dozer can do it. You can check if it works on Android. – dierre Aug 01 '13 at 05:03
  • the reason i want this is: i am using RestTemplate as a rest client and i need FormHttpMessageConverter to post data to the service but it requires a map other than an object as parameter. so i want a easy way to translate an object to a map. @e – juncai Aug 01 '13 at 05:51

0 Answers0