Made every class that can be final final
This commit is contained in:
parent
4bbc4189ec
commit
eb4e421974
@ -17,7 +17,7 @@ import envoy.client.ui.Startup;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class Main {
|
||||
public final class Main {
|
||||
|
||||
private static final boolean debug = false;
|
||||
|
||||
|
@ -17,7 +17,7 @@ import envoy.data.Config;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class ClientConfig extends Config {
|
||||
public final class ClientConfig extends Config {
|
||||
|
||||
private static ClientConfig config;
|
||||
|
||||
|
@ -21,7 +21,7 @@ import envoy.event.GroupMessageStatusChange;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class GroupChat extends Chat {
|
||||
public final class GroupChat extends Chat {
|
||||
|
||||
private final User sender;
|
||||
|
||||
@ -41,13 +41,10 @@ public class GroupChat extends Chat {
|
||||
public void read(WriteProxy writeProxy) throws IOException {
|
||||
for (int i = messages.size() - 1; i >= 0; --i) {
|
||||
final GroupMessage gmsg = (GroupMessage) messages.get(i);
|
||||
if (gmsg.getSenderID() != sender.getID()) {
|
||||
if (gmsg.getMemberStatuses().get(sender.getID()) == MessageStatus.READ) break;
|
||||
else {
|
||||
gmsg.getMemberStatuses().replace(sender.getID(), MessageStatus.READ);
|
||||
writeProxy
|
||||
.writeMessageStatusChange(new GroupMessageStatusChange(gmsg.getID(), MessageStatus.READ, Instant.now(), sender.getID()));
|
||||
}
|
||||
if (gmsg.getSenderID() != sender.getID()) if (gmsg.getMemberStatuses().get(sender.getID()) == MessageStatus.READ) break;
|
||||
else {
|
||||
gmsg.getMemberStatuses().replace(sender.getID(), MessageStatus.READ);
|
||||
writeProxy.writeMessageStatusChange(new GroupMessageStatusChange(gmsg.getID(), MessageStatus.READ, Instant.now(), sender.getID()));
|
||||
}
|
||||
}
|
||||
unreadAmount = 0;
|
||||
|
@ -22,7 +22,7 @@ import envoy.util.SerializationUtils;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public class Settings {
|
||||
public final class Settings {
|
||||
|
||||
// Actual settings accessible by the rest of the application
|
||||
private Map<String, SettingsItem<?>> items;
|
||||
@ -139,7 +139,9 @@ public class Settings {
|
||||
* before
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public void setDownloadSavedWithoutAsking(boolean autosaveDownload) { ((SettingsItem<Boolean>) items.get("autoSaveDownloads")).set(autosaveDownload); }
|
||||
public void setDownloadSavedWithoutAsking(boolean autosaveDownload) {
|
||||
((SettingsItem<Boolean>) items.get("autoSaveDownloads")).set(autosaveDownload);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the path where downloads should be saved
|
||||
|
@ -17,7 +17,7 @@ import javax.swing.JComponent;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public class SettingsItem<T> implements Serializable {
|
||||
public final class SettingsItem<T> implements Serializable {
|
||||
|
||||
private T value;
|
||||
private String userFriendlyName, description;
|
||||
|
@ -24,7 +24,7 @@ import java.util.function.Supplier;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class SystemCommand implements OnCall {
|
||||
public final class SystemCommand implements OnCall {
|
||||
|
||||
protected int relevance;
|
||||
|
||||
|
@ -14,7 +14,7 @@ import java.util.function.Consumer;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class SystemCommandBuilder {
|
||||
public final class SystemCommandBuilder {
|
||||
|
||||
private int numberOfArguments;
|
||||
private Consumer<List<String>> action;
|
||||
|
@ -11,7 +11,7 @@ import envoy.event.Event;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public class MessageCreationEvent extends Event<Message> {
|
||||
public final class MessageCreationEvent extends Event<Message> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
|
@ -11,7 +11,7 @@ import envoy.event.Event;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public class MessageModificationEvent extends Event<Message> {
|
||||
public final class MessageModificationEvent extends Event<Message> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import envoy.event.Event;
|
||||
* @author: Maximilian Käfer
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public class SendEvent extends Event<Event<?>> {
|
||||
public final class SendEvent extends Event<Event<?>> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import envoy.event.Event;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public class ThemeChangeEvent extends Event<String> {
|
||||
public final class ThemeChangeEvent extends Event<String> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
|
@ -29,7 +29,7 @@ import envoy.util.SerializationUtils;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.1-alpha
|
||||
*/
|
||||
public class Client implements Closeable {
|
||||
public final class Client implements Closeable {
|
||||
|
||||
// Connection handling
|
||||
private Socket socket;
|
||||
|
@ -16,7 +16,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class GroupMessageStatusChangeProcessor implements Consumer<GroupMessageStatusChange> {
|
||||
public final class GroupMessageStatusChangeProcessor implements Consumer<GroupMessageStatusChange> {
|
||||
|
||||
private static final Logger logger = EnvoyLog.getLogger(GroupMessageStatusChangeProcessor.class);
|
||||
|
||||
|
@ -16,7 +16,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public class MessageStatusChangeProcessor implements Consumer<MessageStatusChange> {
|
||||
public final class MessageStatusChangeProcessor implements Consumer<MessageStatusChange> {
|
||||
|
||||
private static final Logger logger = EnvoyLog.getLogger(MessageStatusChangeProcessor.class);
|
||||
|
||||
|
@ -17,7 +17,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class ReceivedGroupMessageProcessor implements Consumer<GroupMessage> {
|
||||
public final class ReceivedGroupMessageProcessor implements Consumer<GroupMessage> {
|
||||
|
||||
private static final Logger logger = EnvoyLog.getLogger(ReceivedGroupMessageProcessor.class);
|
||||
|
||||
|
@ -15,7 +15,7 @@ import envoy.event.EventBus;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public class ReceivedMessageProcessor implements Consumer<Message> {
|
||||
public final class ReceivedMessageProcessor implements Consumer<Message> {
|
||||
|
||||
@Override
|
||||
public void accept(Message message) {
|
||||
|
@ -22,7 +22,7 @@ import envoy.util.SerializationUtils;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public class Receiver extends Thread {
|
||||
public final class Receiver extends Thread {
|
||||
|
||||
private boolean isAlive = true;
|
||||
|
||||
|
@ -22,7 +22,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public class WriteProxy {
|
||||
public final class WriteProxy {
|
||||
|
||||
private final Client client;
|
||||
private final LocalDB localDB;
|
||||
@ -68,9 +68,7 @@ public class WriteProxy {
|
||||
*
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public void flushCache() {
|
||||
localDB.getCacheMap().getMap().values().forEach(Cache::relay);
|
||||
}
|
||||
public void flushCache() { localDB.getCacheMap().getMap().values().forEach(Cache::relay); }
|
||||
|
||||
/**
|
||||
* Delivers a message to the server if online. Otherwise the message is cached
|
||||
|
@ -22,7 +22,7 @@ import javafx.scene.layout.GridPane;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class ClearableTextField extends GridPane {
|
||||
public final class ClearableTextField extends GridPane {
|
||||
|
||||
private final TextField textField;
|
||||
|
||||
@ -88,82 +88,82 @@ public class ClearableTextField extends GridPane {
|
||||
* @see javafx.scene.control.TextInputControl#promptTextProperty()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final StringProperty promptTextProperty() { return textField.promptTextProperty(); }
|
||||
public StringProperty promptTextProperty() { return textField.promptTextProperty(); }
|
||||
|
||||
/**
|
||||
* @return the current prompt text
|
||||
* @see javafx.scene.control.TextInputControl#getPromptText()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final String getPromptText() { return textField.getPromptText(); }
|
||||
public String getPromptText() { return textField.getPromptText(); }
|
||||
|
||||
/**
|
||||
* @param value the prompt text to display
|
||||
* @see javafx.scene.control.TextInputControl#setPromptText(java.lang.String)
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final void setPromptText(String value) { textField.setPromptText(value); }
|
||||
public void setPromptText(String value) { textField.setPromptText(value); }
|
||||
|
||||
/**
|
||||
* @return the current property of the tooltip
|
||||
* @see javafx.scene.control.Control#tooltipProperty()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final ObjectProperty<Tooltip> tooltipProperty() { return textField.tooltipProperty(); }
|
||||
public ObjectProperty<Tooltip> tooltipProperty() { return textField.tooltipProperty(); }
|
||||
|
||||
/**
|
||||
* @param value the new tooltip
|
||||
* @see javafx.scene.control.Control#setTooltip(javafx.scene.control.Tooltip)
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final void setTooltip(Tooltip value) { textField.setTooltip(value); }
|
||||
public void setTooltip(Tooltip value) { textField.setTooltip(value); }
|
||||
|
||||
/**
|
||||
* @return the current tooltip
|
||||
* @see javafx.scene.control.Control#getTooltip()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final Tooltip getTooltip() { return textField.getTooltip(); }
|
||||
public Tooltip getTooltip() { return textField.getTooltip(); }
|
||||
|
||||
/**
|
||||
* @return the current property of the context menu
|
||||
* @see javafx.scene.control.Control#contextMenuProperty()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final ObjectProperty<ContextMenu> contextMenuProperty() { return textField.contextMenuProperty(); }
|
||||
public ObjectProperty<ContextMenu> contextMenuProperty() { return textField.contextMenuProperty(); }
|
||||
|
||||
/**
|
||||
* @param value the new context menu
|
||||
* @see javafx.scene.control.Control#setContextMenu(javafx.scene.control.ContextMenu)
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final void setContextMenu(ContextMenu value) { textField.setContextMenu(value); }
|
||||
public void setContextMenu(ContextMenu value) { textField.setContextMenu(value); }
|
||||
|
||||
/**
|
||||
* @return the current context menu
|
||||
* @see javafx.scene.control.Control#getContextMenu()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final ContextMenu getContextMenu() { return textField.getContextMenu(); }
|
||||
public ContextMenu getContextMenu() { return textField.getContextMenu(); }
|
||||
|
||||
/**
|
||||
* @param value whether this ClearableTextField should be editable
|
||||
* @see javafx.scene.control.TextInputControl#setEditable(boolean)
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final void setEditable(boolean value) { textField.setEditable(value); }
|
||||
public void setEditable(boolean value) { textField.setEditable(value); }
|
||||
|
||||
/**
|
||||
* @return the current property whether this ClearableTextField is editable
|
||||
* @see javafx.scene.control.TextInputControl#editableProperty()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final BooleanProperty editableProperty() { return textField.editableProperty(); }
|
||||
public BooleanProperty editableProperty() { return textField.editableProperty(); }
|
||||
|
||||
/**
|
||||
* @return whether this {@code ClearableTextField} is editable
|
||||
* @see javafx.scene.control.TextInputControl#isEditable()
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public final boolean isEditable() { return textField.isEditable(); }
|
||||
public boolean isEditable() { return textField.isEditable(); }
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class IconUtil {
|
||||
public final class IconUtil {
|
||||
|
||||
private IconUtil() {}
|
||||
|
||||
@ -160,7 +160,7 @@ public class IconUtil {
|
||||
BufferedImage image = null;
|
||||
try {
|
||||
image = ImageIO.read(IconUtil.class.getResource(path));
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
EnvoyLog.getLogger(IconUtil.class).log(Level.WARNING, String.format("Could not load image at path %s: ", path), e);
|
||||
}
|
||||
return image;
|
||||
|
@ -18,7 +18,7 @@ import envoy.event.EventBus;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public class StatusTrayIcon {
|
||||
public final class StatusTrayIcon {
|
||||
|
||||
/**
|
||||
* The {@link TrayIcon} provided by the System Tray API for controlling the
|
||||
@ -85,7 +85,7 @@ public class StatusTrayIcon {
|
||||
public void show() {
|
||||
try {
|
||||
SystemTray.getSystemTray().add(trayIcon);
|
||||
} catch (AWTException e) {}
|
||||
} catch (final AWTException e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class ContactSearchScene {
|
||||
public final class ContactSearchScene {
|
||||
|
||||
@FXML
|
||||
private ClearableTextField searchBar;
|
||||
|
@ -39,7 +39,7 @@ import envoy.util.Bounds;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class GroupCreationScene {
|
||||
public final class GroupCreationScene {
|
||||
|
||||
@FXML
|
||||
private Button createButton;
|
||||
|
@ -18,7 +18,7 @@ import envoy.client.ui.settings.*;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class SettingsScene {
|
||||
public final class SettingsScene {
|
||||
|
||||
@FXML
|
||||
private ListView<SettingsPane> settingsList;
|
||||
|
@ -23,7 +23,7 @@ import envoy.data.Group;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class ChatControl extends HBox {
|
||||
public final class ChatControl extends HBox {
|
||||
|
||||
/**
|
||||
* @param chat the chat to display
|
||||
@ -36,7 +36,7 @@ public class ChatControl extends HBox {
|
||||
ImageView contactProfilePic;
|
||||
if (chat.getRecipient() instanceof Group) contactProfilePic = new ImageView(IconUtil.loadIconThemeSensitive("group_icon", 32));
|
||||
else contactProfilePic = new ImageView(IconUtil.loadIconThemeSensitive("user_icon", 32));
|
||||
Rectangle clip = new Rectangle();
|
||||
final var clip = new Rectangle();
|
||||
clip.setWidth(32);
|
||||
clip.setHeight(32);
|
||||
clip.setArcHeight(32);
|
||||
@ -44,7 +44,7 @@ public class ChatControl extends HBox {
|
||||
contactProfilePic.setClip(clip);
|
||||
getChildren().add(contactProfilePic);
|
||||
// spacing
|
||||
Region leftSpacing = new Region();
|
||||
final var leftSpacing = new Region();
|
||||
leftSpacing.setPrefSize(8, 0);
|
||||
leftSpacing.setMinSize(8, 0);
|
||||
leftSpacing.setMaxSize(8, 0);
|
||||
|
@ -18,7 +18,7 @@ import envoy.data.User;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class ContactControl extends VBox {
|
||||
public final class ContactControl extends VBox {
|
||||
|
||||
/**
|
||||
* @param contact the contact to display
|
||||
@ -36,9 +36,7 @@ public class ContactControl extends VBox {
|
||||
final var statusLabel = new Label(status);
|
||||
statusLabel.getStyleClass().add(status.toLowerCase());
|
||||
getChildren().add(statusLabel);
|
||||
} else {
|
||||
getChildren().add(new Label(contact.getContacts().size() + " members"));
|
||||
}
|
||||
} else getChildren().add(new Label(contact.getContacts().size() + " members"));
|
||||
getStyleClass().add("listElement");
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import envoy.client.data.Settings;
|
||||
import envoy.client.ui.AudioControl;
|
||||
import envoy.client.ui.IconUtil;
|
||||
import envoy.client.ui.SceneContext;
|
||||
|
||||
import envoy.data.GroupMessage;
|
||||
import envoy.data.Message;
|
||||
import envoy.data.Message.MessageStatus;
|
||||
@ -42,7 +41,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class MessageControl extends Label {
|
||||
public final class MessageControl extends Label {
|
||||
|
||||
private boolean ownMessage;
|
||||
|
||||
|
@ -21,7 +21,7 @@ import envoy.event.IssueProposal;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class BugReportPane extends OnlyIfOnlineSettingsPane {
|
||||
public final class BugReportPane extends OnlyIfOnlineSettingsPane {
|
||||
|
||||
private final Label titleLabel = new Label("Suggest a title for the bug:");
|
||||
private final TextField titleTextField = new TextField();
|
||||
|
@ -17,7 +17,7 @@ import envoy.client.ui.SceneContext;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class DownloadSettingsPane extends SettingsPane {
|
||||
public final class DownloadSettingsPane extends SettingsPane {
|
||||
|
||||
/**
|
||||
* Constructs a new {@code DownloadSettingsPane}.
|
||||
|
@ -16,7 +16,7 @@ import envoy.event.EventBus;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Client v0.1-beta
|
||||
*/
|
||||
public class GeneralSettingsPane extends SettingsPane {
|
||||
public final class GeneralSettingsPane extends SettingsPane {
|
||||
|
||||
/**
|
||||
* @since Envoy Client v0.1-beta
|
||||
|
@ -35,7 +35,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class UserSettingsPane extends OnlyIfOnlineSettingsPane {
|
||||
public final class UserSettingsPane extends OnlyIfOnlineSettingsPane {
|
||||
|
||||
private boolean profilePicChanged, usernameChanged, validPassword;
|
||||
private byte[] currentImageBytes;
|
||||
|
@ -10,7 +10,7 @@ package envoy.client.util;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class IssueUtil {
|
||||
public final class IssueUtil {
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -15,7 +15,7 @@ import javafx.scene.Node;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class ReflectionUtil {
|
||||
public final class ReflectionUtil {
|
||||
|
||||
private ReflectionUtil() {}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import java.io.Serializable;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class Attachment implements Serializable {
|
||||
public final class Attachment implements Serializable {
|
||||
|
||||
/**
|
||||
* Defines the type of the attachment.
|
||||
|
@ -14,7 +14,7 @@ import java.util.function.Function;
|
||||
* @param <T> the type of the config item's value
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class ConfigItem<T> {
|
||||
public final class ConfigItem<T> {
|
||||
|
||||
private final String commandLong, commandShort;
|
||||
private final Function<String, T> parseFunction;
|
||||
|
@ -12,7 +12,7 @@ import java.io.Serializable;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class IDGenerator implements Serializable {
|
||||
public final class IDGenerator implements Serializable {
|
||||
|
||||
private final long end;
|
||||
private long current;
|
||||
|
@ -16,13 +16,13 @@ import envoy.data.Message.MessageStatus;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class MessageBuilder {
|
||||
public final class MessageBuilder {
|
||||
|
||||
// Mandatory properties without default values
|
||||
private final long senderID, recipientID;
|
||||
|
||||
// Properties with default values
|
||||
private long id;
|
||||
private final long id;
|
||||
private Instant creationDate, receivedDate, readDate;
|
||||
private String text;
|
||||
private Attachment attachment;
|
||||
@ -69,11 +69,11 @@ public class MessageBuilder {
|
||||
*/
|
||||
public MessageBuilder(Message msg, long recipientID, IDGenerator iDGenerator) {
|
||||
this(msg.getRecipientID(), recipientID, iDGenerator.next());
|
||||
this.attachment = msg.getAttachment();
|
||||
this.creationDate = Instant.now();
|
||||
this.forwarded = true;
|
||||
this.text = msg.getText();
|
||||
this.status = MessageStatus.WAITING;
|
||||
attachment = msg.getAttachment();
|
||||
creationDate = Instant.now();
|
||||
forwarded = true;
|
||||
text = msg.getText();
|
||||
status = MessageStatus.WAITING;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,7 +128,7 @@ public class MessageBuilder {
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public GroupMessage buildGroupMessage(Group group) {
|
||||
var memberStatuses = new HashMap<Long, Message.MessageStatus>();
|
||||
final var memberStatuses = new HashMap<Long, Message.MessageStatus>();
|
||||
group.getContacts().forEach(user -> memberStatuses.put(user.getID(), MessageStatus.WAITING));
|
||||
return buildGroupMessage(group, memberStatuses);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import java.util.function.Consumer;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy v0.2-alpha
|
||||
*/
|
||||
public class EventBus {
|
||||
public final class EventBus {
|
||||
|
||||
/**
|
||||
* Contains all event handler instances registered at this event bus as values
|
||||
|
@ -15,7 +15,7 @@ import envoy.data.User;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class GroupCreation extends Event<String> {
|
||||
public final class GroupCreation extends Event<String> {
|
||||
|
||||
private final Set<Long> initialMemberIDs;
|
||||
|
||||
|
@ -13,7 +13,7 @@ import envoy.data.Message.MessageStatus;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class GroupMessageStatusChange extends MessageStatusChange {
|
||||
public final class GroupMessageStatusChange extends MessageStatusChange {
|
||||
|
||||
private final long memberID;
|
||||
|
||||
|
@ -17,7 +17,7 @@ import envoy.data.User;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class GroupResize extends Event<User> {
|
||||
public final class GroupResize extends Event<User> {
|
||||
|
||||
private final long groupID;
|
||||
private final ElementOperation operation;
|
||||
|
@ -11,7 +11,7 @@ package envoy.event;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.3-alpha
|
||||
*/
|
||||
public class HandshakeRejection extends Event<String> {
|
||||
public final class HandshakeRejection extends Event<String> {
|
||||
|
||||
/**
|
||||
* Select this value if a given password hash or user name was incorrect.
|
||||
|
@ -11,7 +11,7 @@ package envoy.event;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.3-alpha
|
||||
*/
|
||||
public class IDGeneratorRequest extends Event.Valueless {
|
||||
public final class IDGeneratorRequest extends Event.Valueless {
|
||||
|
||||
private static final long serialVersionUID = 1431107413883364583L;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ package envoy.event;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Client v0.2-beta
|
||||
*/
|
||||
public class IsTyping extends Event<Long> {
|
||||
public final class IsTyping extends Event<Long> {
|
||||
|
||||
private final long destinationID;
|
||||
|
||||
|
@ -11,7 +11,7 @@ package envoy.event;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.2-beta
|
||||
*/
|
||||
public class IssueProposal extends Event<String> {
|
||||
public final class IssueProposal extends Event<String> {
|
||||
|
||||
private final String description;
|
||||
private final boolean bug;
|
||||
|
@ -14,7 +14,7 @@ import envoy.data.Contact;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class NameChange extends Event<String> {
|
||||
public final class NameChange extends Event<String> {
|
||||
|
||||
private final long id;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import envoy.data.Contact;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.2-beta
|
||||
*/
|
||||
public class PasswordChangeRequest extends Event<String> {
|
||||
public final class PasswordChangeRequest extends Event<String> {
|
||||
|
||||
private final long id;
|
||||
private final String oldPassword;
|
||||
|
@ -11,7 +11,7 @@ package envoy.event;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.2-beta
|
||||
*/
|
||||
public class PasswordChangeResult extends Event<Boolean> {
|
||||
public final class PasswordChangeResult extends Event<Boolean> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -8,7 +8,7 @@ package envoy.event;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.2-beta
|
||||
*/
|
||||
public class ProfilePicChange extends Event<byte[]> {
|
||||
public final class ProfilePicChange extends Event<byte[]> {
|
||||
|
||||
private final long id;
|
||||
|
||||
|
@ -11,7 +11,7 @@ import envoy.data.User.UserStatus;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class UserStatusChange extends Event<UserStatus> {
|
||||
public final class UserStatusChange extends Event<UserStatus> {
|
||||
|
||||
private final long id;
|
||||
|
||||
|
@ -14,7 +14,7 @@ import envoy.event.Event;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class ContactOperation extends Event<Contact> {
|
||||
public final class ContactOperation extends Event<Contact> {
|
||||
|
||||
private final ElementOperation operationType;
|
||||
|
||||
|
@ -12,7 +12,7 @@ import envoy.event.Event;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class UserSearchRequest extends Event<String> {
|
||||
public final class UserSearchRequest extends Event<String> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
|
@ -15,7 +15,7 @@ import envoy.event.Event;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class UserSearchResult extends Event<List<User>> {
|
||||
public final class UserSearchResult extends Event<List<User>> {
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
|
@ -8,7 +8,7 @@ package envoy.exception;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public class EnvoyException extends Exception {
|
||||
public final class EnvoyException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 2096147309395387479L;
|
||||
|
||||
|
@ -12,7 +12,7 @@ import java.util.regex.Pattern;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class Bounds {
|
||||
public final class Bounds {
|
||||
|
||||
private Bounds() {}
|
||||
|
||||
|
@ -20,7 +20,7 @@ import envoy.data.Config;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public class EnvoyLog {
|
||||
public final class EnvoyLog {
|
||||
|
||||
private static FileHandler fileHandler;
|
||||
private static StreamHandler consoleHandler;
|
||||
|
@ -12,7 +12,7 @@ import java.io.*;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public class SerializationUtils {
|
||||
public final class SerializationUtils {
|
||||
|
||||
private SerializationUtils() {}
|
||||
|
||||
|
@ -24,7 +24,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public class Startup {
|
||||
public final class Startup {
|
||||
|
||||
/**
|
||||
* Stores the configuration used for the whole server
|
||||
|
@ -14,7 +14,7 @@ import javax.persistence.Table;
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "configuration")
|
||||
public class ConfigItem {
|
||||
public final class ConfigItem {
|
||||
|
||||
@Id
|
||||
private String key;
|
||||
|
@ -28,7 +28,7 @@ import javax.persistence.NamedQuery;
|
||||
query = "SELECT g FROM Group g WHERE g.creationDate > :lastSeen AND :user MEMBER OF g.contacts"
|
||||
)
|
||||
})
|
||||
public class Group extends Contact {
|
||||
public final class Group extends Contact {
|
||||
|
||||
/**
|
||||
* Named query retrieving a group by name (parameter {@code :name}).
|
||||
|
@ -24,7 +24,7 @@ import envoy.data.Group;
|
||||
+ "OR m.status = envoy.data.Message$MessageStatus.READ AND m.readDate > :lastSeen "
|
||||
+ "OR m.lastStatusChangeDate > :lastSeen)"
|
||||
)
|
||||
public class GroupMessage extends Message {
|
||||
public final class GroupMessage extends Message {
|
||||
|
||||
/**
|
||||
* Named query retrieving pending group messages sent to a group containing a
|
||||
|
@ -19,7 +19,7 @@ import envoy.server.net.ConnectionManager;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public class PersistenceManager {
|
||||
public final class PersistenceManager {
|
||||
|
||||
private final EntityManager entityManager = Persistence.createEntityManagerFactory("envoy").createEntityManager();
|
||||
private final EntityTransaction transaction = entityManager.getTransaction();
|
||||
|
@ -12,7 +12,7 @@ import envoy.data.Config;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Server v0.2-beta
|
||||
*/
|
||||
public class ServerConfig extends Config {
|
||||
public final class ServerConfig extends Config {
|
||||
|
||||
private static ServerConfig config;
|
||||
|
||||
|
@ -36,7 +36,7 @@ import envoy.data.User.UserStatus;
|
||||
query = "SELECT u FROM User u WHERE (lower(u.name) LIKE lower(:searchPhrase) AND u <> :context AND :context NOT MEMBER OF u.contacts)"
|
||||
)
|
||||
})
|
||||
public class User extends Contact {
|
||||
public final class User extends Contact {
|
||||
|
||||
/**
|
||||
* Named query retrieving a user by name (parameter {@code :name}).
|
||||
|
@ -19,7 +19,7 @@ import envoy.server.processors.UserStatusChangeProcessor;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public class ConnectionManager implements ISocketIdListener {
|
||||
public final class ConnectionManager implements ISocketIdListener {
|
||||
|
||||
/**
|
||||
* Contains all socket IDs that have not yet performed a handshake / acquired
|
||||
|
@ -25,7 +25,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public class ObjectMessageProcessor implements IMessageProcessor {
|
||||
public final class ObjectMessageProcessor implements IMessageProcessor {
|
||||
|
||||
private final Set<ObjectProcessor<?>> processors;
|
||||
|
||||
|
@ -19,7 +19,7 @@ import envoy.util.SerializationUtils;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public class ObjectMessageReader implements IMessageReader {
|
||||
public final class ObjectMessageReader implements IMessageReader {
|
||||
|
||||
private List<Message> completeMessages = new ArrayList<>();
|
||||
private Message nextMessage;
|
||||
|
@ -22,7 +22,7 @@ import envoy.util.SerializationUtils;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public class ObjectWriteProxy {
|
||||
public final class ObjectWriteProxy {
|
||||
|
||||
private final WriteProxy writeProxy;
|
||||
|
||||
|
@ -17,7 +17,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public class ContactOperationProcessor implements ObjectProcessor<ContactOperation> {
|
||||
public final class ContactOperationProcessor implements ObjectProcessor<ContactOperation> {
|
||||
|
||||
private static final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||
private static final Logger logger = EnvoyLog.getLogger(ContactOperationProcessor.class);
|
||||
|
@ -18,7 +18,7 @@ import envoy.server.net.ObjectWriteProxy;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public class GroupCreationProcessor implements ObjectProcessor<GroupCreation> {
|
||||
public final class GroupCreationProcessor implements ObjectProcessor<GroupCreation> {
|
||||
|
||||
private final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||
private final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||
|
@ -23,7 +23,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public class GroupMessageProcessor implements ObjectProcessor<GroupMessage> {
|
||||
public final class GroupMessageProcessor implements ObjectProcessor<GroupMessage> {
|
||||
|
||||
private static final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||
|
@ -24,7 +24,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public class GroupMessageStatusChangeProcessor implements ObjectProcessor<GroupMessageStatusChange> {
|
||||
public final class GroupMessageStatusChangeProcessor implements ObjectProcessor<GroupMessageStatusChange> {
|
||||
|
||||
private static final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||
|
@ -14,7 +14,7 @@ import envoy.server.net.ObjectWriteProxy;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public class GroupResizeProcessor implements ObjectProcessor<GroupResize> {
|
||||
public final class GroupResizeProcessor implements ObjectProcessor<GroupResize> {
|
||||
|
||||
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||
private static final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||
|
@ -17,7 +17,7 @@ import envoy.server.net.ObjectWriteProxy;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public class IDGeneratorRequestProcessor implements ObjectProcessor<IDGeneratorRequest> {
|
||||
public final class IDGeneratorRequestProcessor implements ObjectProcessor<IDGeneratorRequest> {
|
||||
|
||||
private static final long ID_RANGE = 200;
|
||||
|
||||
|
@ -18,7 +18,7 @@ import envoy.server.net.ObjectWriteProxy;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Server v0.2-beta
|
||||
*/
|
||||
public class IsTypingProcessor implements ObjectProcessor<IsTyping> {
|
||||
public final class IsTypingProcessor implements ObjectProcessor<IsTyping> {
|
||||
|
||||
private static final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||
|
@ -23,7 +23,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Server v0.2-beta
|
||||
*/
|
||||
public class IssueProposalProcessor implements ObjectProcessor<IssueProposal> {
|
||||
public final class IssueProposalProcessor implements ObjectProcessor<IssueProposal> {
|
||||
|
||||
private static final Logger logger = EnvoyLog.getLogger(IssueProposalProcessor.class);
|
||||
|
||||
|
@ -23,7 +23,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public class MessageProcessor implements ObjectProcessor<Message> {
|
||||
public final class MessageProcessor implements ObjectProcessor<Message> {
|
||||
|
||||
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||
private static final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||
|
@ -19,7 +19,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public class MessageStatusChangeProcessor implements ObjectProcessor<MessageStatusChange> {
|
||||
public final class MessageStatusChangeProcessor implements ObjectProcessor<MessageStatusChange> {
|
||||
|
||||
private final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||
private final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||
|
@ -15,7 +15,7 @@ import envoy.server.net.ObjectWriteProxy;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public class NameChangeProcessor implements ObjectProcessor<NameChange> {
|
||||
public final class NameChangeProcessor implements ObjectProcessor<NameChange> {
|
||||
|
||||
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||
|
||||
|
@ -18,7 +18,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Server v0.2-beta
|
||||
*/
|
||||
public class PasswordChangeRequestProcessor implements ObjectProcessor<PasswordChangeRequest> {
|
||||
public final class PasswordChangeRequestProcessor implements ObjectProcessor<PasswordChangeRequest> {
|
||||
|
||||
@Override
|
||||
public void process(PasswordChangeRequest event, long socketID, ObjectWriteProxy writeProxy) throws IOException {
|
||||
|
@ -13,7 +13,7 @@ import envoy.server.net.ObjectWriteProxy;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Server v0.2-beta
|
||||
*/
|
||||
public class ProfilePicChangeProcessor implements ObjectProcessor<ProfilePicChange> {
|
||||
public final class ProfilePicChangeProcessor implements ObjectProcessor<ProfilePicChange> {
|
||||
|
||||
@Override
|
||||
public void process(ProfilePicChange event, long socketID, ObjectWriteProxy writeProxy) throws IOException {}
|
||||
|
@ -20,7 +20,7 @@ import envoy.server.net.ObjectWriteProxy;
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public class UserSearchProcessor implements ObjectProcessor<UserSearchRequest> {
|
||||
public final class UserSearchProcessor implements ObjectProcessor<UserSearchRequest> {
|
||||
|
||||
/**
|
||||
* Writes a list of contacts to the client containing all {@link Contact}s
|
||||
|
@ -19,7 +19,7 @@ import envoy.util.EnvoyLog;
|
||||
* @author Leon Hofmeister
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public class UserStatusChangeProcessor implements ObjectProcessor<UserStatusChange> {
|
||||
public final class UserStatusChangeProcessor implements ObjectProcessor<UserStatusChange> {
|
||||
|
||||
private static ObjectWriteProxy writeProxy;
|
||||
|
||||
|
@ -19,7 +19,7 @@ import javax.crypto.spec.PBEKeySpec;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public class PasswordUtil {
|
||||
public final class PasswordUtil {
|
||||
|
||||
private static final int ITERATIONS = 1000;
|
||||
private static final int KEY_LENGTH = 64 * 8;
|
||||
|
@ -13,7 +13,7 @@ import java.util.regex.Pattern;
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
public class VersionUtil {
|
||||
public final class VersionUtil {
|
||||
|
||||
/**
|
||||
* The minimal client version compatible with this server.
|
||||
|
Reference in New Issue
Block a user