mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2026-09-30 00:02:39 +00:00
Expanded Message model by getId(); added tests for both supported api layers.
This commit is contained in:
1 parent
3d2b07eae9
commit
b26df3639e
3 files changed
+56
-5
No files matched your search
@@ -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