Made every class that can be final final

This commit is contained in:
delvh
2020-08-22 13:37:07 +02:00
parent 4bbc4189ec
commit eb4e421974
85 changed files with 123 additions and 129 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,7 +13,7 @@ import envoy.data.Message.MessageStatus;
* @author Maximilian K&auml;fer
* @since Envoy Common v0.1-beta
*/
public class GroupMessageStatusChange extends MessageStatusChange {
public final class GroupMessageStatusChange extends MessageStatusChange {
private final long memberID;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,7 @@ import envoy.event.Event;
* @author Maximilian K&auml;fer
* @since Envoy Common v0.2-alpha
*/
public class ContactOperation extends Event<Contact> {
public final class ContactOperation extends Event<Contact> {
private final ElementOperation operationType;

View File

@ -12,7 +12,7 @@ import envoy.event.Event;
* @author Maximilian K&auml;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;

View File

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

View File

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

View File

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

View File

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

View File

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