From 640ecbf41bdc16ce78f85f05c6e9030696fd6d4b Mon Sep 17 00:00:00 2001 From: delvh Date: Wed, 30 Sep 2020 13:22:13 +0200 Subject: [PATCH] Apply suggestions from @kske --- client/src/main/java/envoy/client/data/Chat.java | 8 ++++---- client/src/main/java/envoy/client/data/LocalDB.java | 4 ++-- .../src/main/java/envoy/client/event/MessageDeletion.java | 2 +- .../main/java/envoy/client/ui/controller/ChatScene.java | 2 +- client/src/main/java/envoy/client/util/MessageUtil.java | 8 ++++---- .../main/java/envoy/server/data/PersistenceManager.java | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/client/src/main/java/envoy/client/data/Chat.java b/client/src/main/java/envoy/client/data/Chat.java index 75ca5a3..beabf9c 100644 --- a/client/src/main/java/envoy/client/data/Chat.java +++ b/client/src/main/java/envoy/client/data/Chat.java @@ -74,7 +74,7 @@ public class Chat implements Serializable { public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof Chat)) return false; - final Chat other = (Chat) obj; + final var other = (Chat) obj; return Objects.equals(recipient, other.recipient); } @@ -89,7 +89,7 @@ public class Chat implements Serializable { */ public void read(WriteProxy writeProxy) { for (int i = messages.size() - 1; i >= 0; --i) { - final Message m = messages.get(i); + final var m = messages.get(i); if (m.getSenderID() == recipient.getID()) if (m.getStatus() == MessageStatus.READ) break; else { m.setStatus(MessageStatus.READ); @@ -122,10 +122,10 @@ public class Chat implements Serializable { } /** - * Removes the message with the given ID + * Removes the message with the given ID. * * @param messageID the ID of the message to remove - * @return whether any message has been removed + * @return whether the message has been found and removed * @since Envoy Client v0.3-beta */ public boolean remove(long messageID) { return messages.removeIf(m -> m.getID() == messageID); } diff --git a/client/src/main/java/envoy/client/data/LocalDB.java b/client/src/main/java/envoy/client/data/LocalDB.java index f99913c..51fb2cc 100644 --- a/client/src/main/java/envoy/client/data/LocalDB.java +++ b/client/src/main/java/envoy/client/data/LocalDB.java @@ -275,12 +275,12 @@ public final class LocalDB implements EventListener { } /** - * Deletes the message with the given ID, if any is present. + * Deletes the message with the given ID, if present. * * @param message the event that was * @since Envoy Client v0.3-beta */ - @Event() + @Event private void onMessageDeletion(MessageDeletion message) { Platform.runLater(() -> { diff --git a/client/src/main/java/envoy/client/event/MessageDeletion.java b/client/src/main/java/envoy/client/event/MessageDeletion.java index df0bb0b..e3f5ada 100644 --- a/client/src/main/java/envoy/client/event/MessageDeletion.java +++ b/client/src/main/java/envoy/client/event/MessageDeletion.java @@ -3,7 +3,7 @@ package envoy.client.event; import envoy.event.Event; /** - * Conveys the deletion of a message between clients and server. + * Conveys the deletion of a message. * * @author Leon Hofmeister * @since Envoy Common v0.3-beta diff --git a/client/src/main/java/envoy/client/ui/controller/ChatScene.java b/client/src/main/java/envoy/client/ui/controller/ChatScene.java index e3de0fc..a4ef479 100644 --- a/client/src/main/java/envoy/client/ui/controller/ChatScene.java +++ b/client/src/main/java/envoy/client/ui/controller/ChatScene.java @@ -772,7 +772,7 @@ public final class ChatScene implements EventListener, Restorable { } /** - * Clears the current message selection + * Clears the current message selection. * * @since Envoy Client v0.3-beta */ diff --git a/client/src/main/java/envoy/client/util/MessageUtil.java b/client/src/main/java/envoy/client/util/MessageUtil.java index 62fb132..468e8dc 100644 --- a/client/src/main/java/envoy/client/util/MessageUtil.java +++ b/client/src/main/java/envoy/client/util/MessageUtil.java @@ -47,7 +47,7 @@ public class MessageUtil { public static void deleteMessage(Message message) { final var messageDeletionEvent = new MessageDeletion(message.getID()); final var controller = Context.getInstance().getSceneContext().getController(); - if (controller.getClass().equals(ChatScene.class)) ((ChatScene) controller).clearMessageSelection(); + if (controller instanceof ChatScene) ((ChatScene) controller).clearMessageSelection(); // Removing the message locally EventBus.getInstance().dispatch(messageDeletionEvent); @@ -62,7 +62,7 @@ public class MessageUtil { * @param message the message to forward * @since Envoy Client v0.3-beta */ - public static void forwardMessage(Message message) { logger.log(Level.FINEST, "message forwarding was requested for " + message); } + public static void forwardMessage(Message message) { logger.log(Level.FINEST, "Message forwarding was requested for " + message); } /** * Quotes the given message. @@ -71,7 +71,7 @@ public class MessageUtil { * @param message the message to quote * @since Envoy Client v0.3-beta */ - public static void quoteMessage(Message message) { logger.log(Level.FINEST, "message quotation was requested for " + message); } + public static void quoteMessage(Message message) { logger.log(Level.FINEST, "Message quotation was requested for " + message); } /** * Saves the attachment of a message, if present. @@ -81,7 +81,7 @@ public class MessageUtil { * @since Envoy Client v0.3-beta */ public static void saveAttachment(Message message) { - if (!message.hasAttachment()) throw new IllegalStateException("Cannot save a non-existing attachment"); + if (!message.hasAttachment()) throw new IllegalArgumentException("Cannot save a non-existing attachment"); File file; final var fileName = message.getAttachment().getName(); final var downloadLocation = Settings.getInstance().getDownloadLocation(); diff --git a/server/src/main/java/envoy/server/data/PersistenceManager.java b/server/src/main/java/envoy/server/data/PersistenceManager.java index 2946dee..67fa4e9 100755 --- a/server/src/main/java/envoy/server/data/PersistenceManager.java +++ b/server/src/main/java/envoy/server/data/PersistenceManager.java @@ -9,7 +9,7 @@ import envoy.data.User.UserStatus; import envoy.server.net.ConnectionManager; /** - * Contains operations used for data retrieval. + * Contains operations used for persistence. * * @author Leon Hofmeister * @author Maximilian Käfer