I'm hoping someone can suggest a simple solution to my problem.
I have a POJO, say:
public class Person
{
private String name;
public String getName(){ return name; }
public void setName(String name){ this.name = name; }
}
I'd like to use GWT's AutoBean functionality to serialize / deserialize this bean to JSON, but AutoBean expects an interface:
public interface Person
{
public String getName();
public void setName(String name);
}
I have an AutoBeanFactory setup:
public interface PersonFactory extends AutoBeanFactory
{
AutoBean<Person> person();
}
Using the factory and the Person interface, I am able to deserialize a JSON Person:
PersonFactory personFactory = GWT.create(PersonFactory.class);
AutoBean<Person> autoBeanPerson = AutoBeanCodex.decode(personFactory, Person.class, jsonObject.toString());
Person person = autoBeanPerson.as();
However, if I replace the Person interface with the Person class, I receive an AutoBeanFactoryGenerator exception that states: "com.xxx.xxx.Person is not an interface".
How can I use AutoBean serialization / deserialization with my simple POJO?