mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2025-06-29 11:56:26 +00:00
Expanded Message model by getId(); added tests for both supported api layers.
This commit is contained in:
@ -8,18 +8,24 @@ public class Message {
|
||||
protected static String tableName = "messages";
|
||||
private JsonObject json;
|
||||
private String message = null;
|
||||
|
||||
private Integer id = null;
|
||||
|
||||
public Message(String json) {
|
||||
this.json = new JsonParser().parse(json).getAsJsonObject();
|
||||
}
|
||||
|
||||
|
||||
public static Message get(int id) {
|
||||
String json = Database.getInstance().queryString("SELECT json FROM " + tableName + " WHERE id=" + id);
|
||||
return new Message(json);
|
||||
}
|
||||
|
||||
|
||||
public String getMessage() {
|
||||
if (message != null) return message;
|
||||
return message = json.getAsJsonPrimitive("message").getAsString();
|
||||
if (message==null) message=json.getAsJsonPrimitive("message").getAsString();
|
||||
return message;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
if (id==null) id=json.getAsJsonPrimitive("id").getAsInt();
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user