Style: Fixing some linter warnings in ChatModel and Message classes

This commit is contained in:
Mathis Ginkel
2026-04-27 00:17:34 +02:00
parent fe83057049
commit 5663807e29
3 changed files with 6 additions and 20 deletions
@@ -2,8 +2,6 @@ package ch.unibas.dmi.dbis.cs108.casono.client.chat;
import java.util.ArrayList;
import java.util.function.Consumer;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
/**
* ChatModel, stores the data for a specific chat
@@ -12,7 +10,7 @@ import javafx.beans.property.SimpleIntegerProperty;
*/
public class ChatModel {
private ArrayList<Consumer<Message>> listeners = new ArrayList<>();
private final ArrayList<Consumer<Message>> listeners = new ArrayList<>();
public ArrayList<Message> messages;
@@ -24,8 +22,6 @@ public class ChatModel {
/** The person to send the message to If the chat is a whisper chat */
private String target;
private final IntegerProperty count;
public int lobbyId;
/**
@@ -37,10 +33,9 @@ public class ChatModel {
* @param target The username of the whisper recipient, or null for other chat types.
*/
public ChatModel(ChatType chattype, String username, int lobbyId, String target) {
this.messages = new ArrayList<Message>();
this.messages = new ArrayList<>();
this.chattype = chattype;
this.username = username;
this.count = new SimpleIntegerProperty(0);
this.lobbyId = lobbyId;
this.target = target;
}
@@ -62,7 +57,7 @@ public class ChatModel {
*/
public synchronized void addMessage(Message msg) {
messages.add(msg);
listeners.stream().forEach((l) -> l.accept(messages.getLast()));
listeners.forEach((l) -> l.accept(messages.getLast()));
}
/**
@@ -15,8 +15,8 @@ public class Message {
private final String message;
public String sender;
public String timestamp;
public int lobbyId = 0;
public String target = null;
public int lobbyId;
public String target;
/**
* Constructs a Message with a provided timestamp. Typically used when reconstructing messages
@@ -100,7 +100,7 @@ public class Message {
* @return A formatted string containing all message attributes for server transmission.
*/
public String toArgsString() {
String gameIdString = "";
String gameIdString;
if (lobbyId >= 0) {
gameIdString = " GAME=" + lobbyId;
} else {
@@ -198,15 +198,6 @@ public class ChatBoxController {
new ChatViewController(
this.chatController, chatModel, this);
ChatKey chatKey;
if (chatType.equals(ChatType.WHISPER)) {
chatKey = new ChatKey(chatType, title);
} else {
chatKey = new ChatKey(chatType);
}
chatController.activeChatControllers.put(chatKey, chatViewController);
this.chatController, chatModel, this.username, this);
ChatKey chatKey;
if (chatType.equals(ChatType.WHISPER)) {
chatKey = new ChatKey(chatType, title);