From 7f62b9bf58dc8aa97127cf582612996674671fae Mon Sep 17 00:00:00 2001 From: Aleksei Date: Fri, 3 Jul 2020 17:04:00 -0400 Subject: [PATCH] Needs to be static --- .../controllers/WelcomeMessageController.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/dev/salmonllama/fsbot/database/controllers/WelcomeMessageController.java b/src/main/java/dev/salmonllama/fsbot/database/controllers/WelcomeMessageController.java index fdb6839..623fa5b 100644 --- a/src/main/java/dev/salmonllama/fsbot/database/controllers/WelcomeMessageController.java +++ b/src/main/java/dev/salmonllama/fsbot/database/controllers/WelcomeMessageController.java @@ -17,7 +17,7 @@ import java.util.concurrent.CompletionException; public class WelcomeMessageController { // Needs insert, update, and delete. Only one per server -> needs exists - public CompletableFuture insert(WelcomeMessage msg) { + public static CompletableFuture insert(WelcomeMessage msg) { return CompletableFuture.runAsync(() -> { try { insertExec(msg); @@ -27,7 +27,7 @@ public class WelcomeMessageController { }); } - public CompletableFuture> get(String id) { + public static CompletableFuture> get(String id) { return CompletableFuture.supplyAsync(() -> { try { return getExec(id); @@ -37,7 +37,7 @@ public class WelcomeMessageController { }); } - public CompletableFuture update(WelcomeMessage msg) { + public static CompletableFuture update(WelcomeMessage msg) { return CompletableFuture.runAsync(() -> { try { updateExec(msg); @@ -47,7 +47,7 @@ public class WelcomeMessageController { }); } - public CompletableFuture exists(String id) { + public static CompletableFuture exists(String id) { return CompletableFuture.supplyAsync(() -> { try { return existsExec(id); @@ -57,7 +57,7 @@ public class WelcomeMessageController { }); } - public CompletableFuture delete(String id) { + public static CompletableFuture delete(String id) { return CompletableFuture.runAsync(() -> { try { deleteExec(id); @@ -67,7 +67,7 @@ public class WelcomeMessageController { }); } - public CompletableFuture delete(WelcomeMessage msg) { + public static CompletableFuture delete(WelcomeMessage msg) { return CompletableFuture.runAsync(() -> { try { deleteExec(msg.getServerId()); @@ -77,7 +77,7 @@ public class WelcomeMessageController { }); } - private void insertExec(WelcomeMessage msg) throws SQLException { + private static void insertExec(WelcomeMessage msg) throws SQLException { FSDB.get().insert("INSERT INTO welcome_messages (server_id, message, updated, editor) VALUES (?, ?, ?, ?)", msg.getServerId(), msg.getMessage(), @@ -86,7 +86,7 @@ public class WelcomeMessageController { ); } - private Optional getExec(String id) throws SQLException { + private static Optional getExec(String id) throws SQLException { ResultSet rs = FSDB.get().select("SELECT * FROM welcome_messages WHERE server_id = ?", id); if (rs.next()) { @@ -99,7 +99,7 @@ public class WelcomeMessageController { return Optional.empty(); } - private void updateExec(WelcomeMessage msg) throws SQLException { + private static void updateExec(WelcomeMessage msg) throws SQLException { FSDB.get().query("UPDATE welcome_messages SET message = ?, updated = ?, editor = ? WHERE server_id = ?", msg.getMessage(), msg.getUpdated(), @@ -108,7 +108,7 @@ public class WelcomeMessageController { ); } - private boolean existsExec(String id) throws SQLException { + private static boolean existsExec(String id) throws SQLException { ResultSet rs = FSDB.get().select("SELECT EXISTS(SELECT 1 FROM welcome_messages WHERE server_id = ?) AS hmm", id); boolean exists = rs.getBoolean("hmm"); @@ -116,11 +116,11 @@ public class WelcomeMessageController { return exists; } - private void deleteExec(String id) throws SQLException { + private static void deleteExec(String id) throws SQLException { FSDB.get().query("DELETE FROM welcome_messages WHERE server_id = ?", id); } - private WelcomeMessage mapObject(ResultSet rs) throws SQLException { + private static WelcomeMessage mapObject(ResultSet rs) throws SQLException { return new WelcomeMessage.WelcomeMessageBuilder(rs.getString("server_id")) .setMessage(rs.getString("message")) .setUpdated(new Timestamp(rs.getLong("updated")))