Apply suggestions from @kske

This commit is contained in:
Leon Hofmeister 2020-09-30 13:22:13 +02:00
parent a5e25321c4
commit 640ecbf41b
Signed by: delvh
GPG Key ID: 3DECE05F6D9A647C
6 changed files with 13 additions and 13 deletions

View File

@ -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); }

View File

@ -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(() -> {

View File

@ -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

View File

@ -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
*/

View File

@ -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();

View File

@ -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