Add identifier

This commit is contained in:
Aleksei 2020-07-03 14:48:18 -04:00
parent 7ad59e3825
commit 2f68e09199

View File

@ -11,16 +11,22 @@ import java.sql.Timestamp;
public class WelcomeMessage extends DatabaseModel { public class WelcomeMessage extends DatabaseModel {
// Need the message, the last time it was updated, and the id of the last person who updated it. // Need the message, the last time it was updated, and the id of the last person who updated it.
private String serverId;
private String message; private String message;
private Timestamp updated; private Timestamp updated;
private String editor; private String editor;
private WelcomeMessage(WelcomeMessageBuilder builder) { private WelcomeMessage(WelcomeMessageBuilder builder) {
serverId = builder.serverId;
message = builder.message; message = builder.message;
updated = builder.updated; updated = builder.updated;
editor = builder.editor; editor = builder.editor;
} }
public String getServerId() {
return serverId;
}
public String getMessage() { public String getMessage() {
return message; return message;
} }
@ -33,21 +39,37 @@ public class WelcomeMessage extends DatabaseModel {
return editor; return editor;
} }
public static String schema() {
return "CREATE TABLE IF NOT EXISTS welcome_messages (" +
"server_id TEXT PRIMARY KEY," +
"message TEXT," +
"updated TEXT," +
"editor TEXT)";
}
public static class WelcomeMessageBuilder { public static class WelcomeMessageBuilder {
private String message; private String serverId;
private String message = null;
private Timestamp updated = null; private Timestamp updated = null;
private String editor = null; private String editor = null;
public WelcomeMessageBuilder(String message) { public WelcomeMessageBuilder(String serverId) {
this.serverId = serverId;
}
public WelcomeMessageBuilder setMessage(String message) {
this.message = message; this.message = message;
return this;
} }
public void setUpdated(Timestamp updated) { public WelcomeMessageBuilder setUpdated(Timestamp updated) {
this.updated = updated; this.updated = updated;
return this;
} }
public void setEditor(String editor) { public WelcomeMessageBuilder setEditor(String editor) {
this.editor = editor; this.editor = editor;
return this;
} }
public WelcomeMessage build() { public WelcomeMessage build() {