How to Use Common Model Class for Retrofit and Squidb
In My Android App, I Am Reading Data from the Server in Json Format and Storing It Local Sqlite Db. I Am Using Retrofit and Gson for Reading and Converting...
In my android app, I am reading data from the server in JSON format and storing it local SQLite db.
I am using retrofit and Gson for reading and converting Json into objects.
For e.g.
@Parcel
public class PersonResponse {
@SerializedName("name")
public String name;
}
I am using Yahoo Squidb as ORM.
@TableModelSpec(className = "Person", tableName = "people")
public class PersonSpec {
@ColumnSpec(name="name", defaultValue="")
public String name;
public static Person create(PersonResponse obj) {
return new Person(obj){...};
}
}
Trouble is I can't use a single object for both. Therefore, it has become pain to maintain two similar pojos.
I have to now convert from PersonResponse to Person
Person p = Person.create(obj_person_response);
Has anyone implemented it. Please suggest.