Merge pull request #23 from informatik-ag-ngl/f/compatibility_verification

LocalDateTime, short event names and compabitility verification support
This commit is contained in:
Kai S. K. Engelbart 2020-06-23 06:25:13 +00:00 committed by GitHub
commit 30c14a7269
13 changed files with 144 additions and 113 deletions

View File

@ -1,7 +1,7 @@
package envoy.data; package envoy.data;
import java.time.LocalDateTime;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.Map; import java.util.Map;
/** /**
@ -38,7 +38,8 @@ public final class GroupMessage extends Message {
* {@link GroupMessage} * {@link GroupMessage}
* @since Envoy Common v0.1-beta * @since Envoy Common v0.1-beta
*/ */
GroupMessage(long id, long senderID, long groupID, Date creationDate, String text, MessageAttachment<?> attachment, MessageStatus status, GroupMessage(long id, long senderID, long groupID, LocalDateTime creationDate, String text, MessageAttachment<?> attachment,
MessageStatus status,
boolean forwarded, Map<Long, MessageStatus> memberStatuses) { boolean forwarded, Map<Long, MessageStatus> memberStatuses) {
super(id, senderID, groupID, creationDate, text, attachment, status, forwarded); super(id, senderID, groupID, creationDate, text, attachment, status, forwarded);
this.memberStatuses = memberStatuses; this.memberStatuses = memberStatuses;
@ -53,10 +54,10 @@ public final class GroupMessage extends Message {
setStatus(Collections.min(memberStatuses.values())); setStatus(Collections.min(memberStatuses.values()));
switch (getStatus()) { switch (getStatus()) {
case RECEIVED: case RECEIVED:
setReceivedDate(new Date()); setReceivedDate(LocalDateTime.now());
break; break;
case READ: case READ:
setReadDate(new Date()); setReadDate(LocalDateTime.now());
break; break;
} }
} }

View File

@ -20,22 +20,25 @@ public class LoginCredentials implements Serializable {
private final String identifier; private final String identifier;
private final byte[] passwordHash; private final byte[] passwordHash;
private final boolean registration; private final boolean registration;
private final String clientVersion;
private static final long serialVersionUID = -7395245059059523314L; private static final long serialVersionUID = 1;
/** /**
* Creates an instance of {@link LoginCredentials} for a new {@link User}. * Creates an instance of {@link LoginCredentials} for a new {@link User}.
* *
* @param identifier the identifier of the user * @param identifier the identifier of the user
* @param password the password of the user (will be converted to a hash) * @param password the password of the user (will be converted to a hash)
* @param registration signifies that these credentials are used for user * @param registration signifies that these credentials are used for user
* registration instead of user login * registration instead of user login
* @param clientVersion the version of the client sending these credentials
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public LoginCredentials(String identifier, char[] password, boolean registration) { public LoginCredentials(String identifier, char[] password, boolean registration, String clientVersion) {
this.identifier = identifier; this.identifier = identifier;
passwordHash = getSha256(toByteArray(password)); passwordHash = getSha256(toByteArray(password));
this.registration = registration; this.registration = registration;
this.clientVersion = clientVersion;
} }
private byte[] getSha256(byte[] input) { private byte[] getSha256(byte[] input) {
@ -84,4 +87,10 @@ public class LoginCredentials implements Serializable {
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public boolean isRegistration() { return registration; } public boolean isRegistration() { return registration; }
/**
* @return the version of the client sending these credentials
* @since Envoy Common v0.1-beta
*/
public String getClientVersion() { return clientVersion; }
} }

View File

@ -1,8 +1,8 @@
package envoy.data; package envoy.data;
import java.io.Serializable; import java.io.Serializable;
import java.text.SimpleDateFormat; import java.time.LocalDateTime;
import java.util.Date; import java.time.format.DateTimeFormatter;
/** /**
* Represents a unique message with a unique, numeric ID. Further metadata * Represents a unique message with a unique, numeric ID. Further metadata
@ -50,14 +50,14 @@ public class Message implements Serializable {
private final long id, senderID, recipientID; private final long id, senderID, recipientID;
private final boolean forwarded; private final boolean forwarded;
private final Date creationDate; private final LocalDateTime creationDate;
private final String text; private final String text;
private final MessageAttachment<?> attachment; private final MessageAttachment<?> attachment;
private Date receivedDate, readDate; private LocalDateTime receivedDate, readDate;
private MessageStatus status; private MessageStatus status;
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 1L;
/** /**
* Initializes a {@link Message} with values for all of its properties. The use * Initializes a {@link Message} with values for all of its properties. The use
@ -75,7 +75,8 @@ public class Message implements Serializable {
* @param forwarded whether this message was forwarded * @param forwarded whether this message was forwarded
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
Message(long id, long senderID, long recipientID, Date creationDate, String text, MessageAttachment<?> attachment, MessageStatus status, Message(long id, long senderID, long recipientID, LocalDateTime creationDate, String text, MessageAttachment<?> attachment,
MessageStatus status,
boolean forwarded) { boolean forwarded) {
this.id = id; this.id = id;
this.senderID = senderID; this.senderID = senderID;
@ -111,7 +112,7 @@ public class Message implements Serializable {
id, id,
senderID, senderID,
recipientID, recipientID,
new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(creationDate), DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss").format(creationDate),
status, status,
text, text,
forwarded, forwarded,
@ -140,32 +141,32 @@ public class Message implements Serializable {
* @return the date at which this message was created * @return the date at which this message was created
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public Date getCreationDate() { return creationDate; } public LocalDateTime getCreationDate() { return creationDate; }
/** /**
* @return the date at which the message has been received by the sender * @return the date at which the message has been received by the sender
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public Date getReceivedDate() { return receivedDate; } public LocalDateTime getReceivedDate() { return receivedDate; }
/** /**
* @param receivedDate the date at which the message has been received by the * @param receivedDate the date at which the message has been received by the
* sender * sender
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public void setReceivedDate(Date receivedDate) { this.receivedDate = receivedDate; } public void setReceivedDate(LocalDateTime receivedDate) { this.receivedDate = receivedDate; }
/** /**
* @return the date at which the message has been read by the sender * @return the date at which the message has been read by the sender
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public Date getReadDate() { return readDate; } public LocalDateTime getReadDate() { return readDate; }
/** /**
* @param readDate at which the message has been read by the sender * @param readDate at which the message has been read by the sender
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public void setReadDate(Date readDate) { this.readDate = readDate; } public void setReadDate(LocalDateTime readDate) { this.readDate = readDate; }
/** /**
* @return the text content of this message * @return the text content of this message

View File

@ -1,6 +1,6 @@
package envoy.data; package envoy.data;
import java.util.Date; import java.time.LocalDateTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -23,7 +23,7 @@ public class MessageBuilder {
// Properties with default values // Properties with default values
private long id; private long id;
private Date creationDate; private LocalDateTime creationDate;
private String text; private String text;
private MessageAttachment<?> attachment; private MessageAttachment<?> attachment;
private Message.MessageStatus status; private Message.MessageStatus status;
@ -70,7 +70,7 @@ public class MessageBuilder {
public MessageBuilder(Message msg, long recipientID, IDGenerator iDGenerator) { public MessageBuilder(Message msg, long recipientID, IDGenerator iDGenerator) {
this(msg.getRecipientID(), recipientID, iDGenerator.next()); this(msg.getRecipientID(), recipientID, iDGenerator.next());
this.attachment = msg.getAttachment(); this.attachment = msg.getAttachment();
this.creationDate = new Date(); this.creationDate = LocalDateTime.now();
this.forwarded = true; this.forwarded = true;
this.text = msg.getText(); this.text = msg.getText();
this.status = MessageStatus.WAITING; this.status = MessageStatus.WAITING;
@ -83,7 +83,7 @@ public class MessageBuilder {
* <table border="1"> * <table border="1">
* <tr> * <tr>
* <td>{@code date}</td> * <td>{@code date}</td>
* <td>{@code new Date()}</td> * <td>{@code LocalDateTime.now()}</td>
* <tr> * <tr>
* <tr> * <tr>
* <td>{@code text}</td> * <td>{@code text}</td>
@ -161,7 +161,7 @@ public class MessageBuilder {
} }
private void supplyDefaults() { private void supplyDefaults() {
if (creationDate == null) creationDate = new Date(); if (creationDate == null) creationDate = LocalDateTime.now();
if (text == null) text = ""; if (text == null) text = "";
if (status == null) status = MessageStatus.WAITING; if (status == null) status = MessageStatus.WAITING;
} }
@ -171,7 +171,7 @@ public class MessageBuilder {
* @return this {@link MessageBuilder} * @return this {@link MessageBuilder}
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public MessageBuilder setDate(Date creationDate) { public MessageBuilder setDate(LocalDateTime creationDate) {
this.creationDate = creationDate; this.creationDate = creationDate;
return this; return this;
} }

View File

@ -9,13 +9,13 @@ import envoy.data.User;
* This event creates a group with the given name.<br> * This event creates a group with the given name.<br>
* <br> * <br>
* Project: <strong>envoy-common</strong><br> * Project: <strong>envoy-common</strong><br>
* File: <strong>GroupCreationEvent.java</strong><br> * File: <strong>GroupCreation.java</strong><br>
* Created: <strong>25 Mar 2020</strong><br> * Created: <strong>25 Mar 2020</strong><br>
* *
* @author Leon Hofmeister * @author Leon Hofmeister
* @since Envoy Common v0.1-beta * @since Envoy Common v0.1-beta
*/ */
public class GroupCreationEvent extends Event<String> { public class GroupCreation extends Event<String> {
private final Set<Long> initialMemberIDs; private final Set<Long> initialMemberIDs;
@ -28,7 +28,7 @@ public class GroupCreationEvent extends Event<String> {
* of this group) * of this group)
* @since Envoy Common v0.1-beta * @since Envoy Common v0.1-beta
*/ */
public GroupCreationEvent(String value, Set<Long> initialMemberIDs) { public GroupCreation(String value, Set<Long> initialMemberIDs) {
super(value); super(value);
this.initialMemberIDs = (initialMemberIDs != null) ? initialMemberIDs : new HashSet<>(); this.initialMemberIDs = (initialMemberIDs != null) ? initialMemberIDs : new HashSet<>();
} }

View File

@ -1,26 +1,26 @@
package envoy.event; package envoy.event;
import java.util.Date; import java.time.LocalDateTime;
import envoy.data.GroupMessage; import envoy.data.GroupMessage;
import envoy.data.Message.MessageStatus; import envoy.data.Message.MessageStatus;
/** /**
* Project: <strong>envoy-common</strong><br> * Project: <strong>envoy-common</strong><br>
* File: <strong>GroupMessageStatusChangeEvent.java</strong><br> * File: <strong>GroupMessageStatusChange.java</strong><br>
* Created: <strong>18.04.2020</strong><br> * Created: <strong>18.04.2020</strong><br>
* *
* @author Maximilian K&auml;fer * @author Maximilian K&auml;fer
* @since Envoy Common v0.1-beta * @since Envoy Common v0.1-beta
*/ */
public class GroupMessageStatusChangeEvent extends MessageStatusChangeEvent { public class GroupMessageStatusChange extends MessageStatusChange {
private final long memberID; private final long memberID;
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;
/** /**
* Initializes a {@link GroupMessageStatusChangeEvent}. * Initializes a {@link GroupMessageStatusChange}.
* *
* @param id the ID of the {@link GroupMessage} this event is related to * @param id the ID of the {@link GroupMessage} this event is related to
* @param status the status of this specific members {@link GroupMessage} * @param status the status of this specific members {@link GroupMessage}
@ -29,7 +29,7 @@ public class GroupMessageStatusChangeEvent extends MessageStatusChangeEvent {
* @param memberID the ID of the group member that caused the status change * @param memberID the ID of the group member that caused the status change
* @since Envoy Common v0.1-beta * @since Envoy Common v0.1-beta
*/ */
public GroupMessageStatusChangeEvent(long id, MessageStatus status, Date date, long memberID) { public GroupMessageStatusChange(long id, MessageStatus status, LocalDateTime date, long memberID) {
super(id, status, date); super(id, status, date);
this.memberID = memberID; this.memberID = memberID;
} }
@ -41,6 +41,5 @@ public class GroupMessageStatusChangeEvent extends MessageStatusChangeEvent {
public long getMemberID() { return memberID; } public long getMemberID() { return memberID; }
@Override @Override
public String toString() { return String.format("GroupMessageStatusChangeEvent[meta=%s,memberID=%d]", super.toString(), memberID); } public String toString() { return String.format("GroupMessageStatusChange[meta=%s,memberID=%d]", super.toString(), memberID); }
} }

View File

@ -11,13 +11,13 @@ import envoy.data.User;
* certain {@link Group}. * certain {@link Group}.
* <br> * <br>
* Project: <strong>envoy-common</strong><br> * Project: <strong>envoy-common</strong><br>
* File: <strong>GroupResizeEvent.java</strong><br> * File: <strong>GroupResize.java</strong><br>
* Created: <strong>25 Mar 2020</strong><br> * Created: <strong>25 Mar 2020</strong><br>
* *
* @author Leon Hofmeister * @author Leon Hofmeister
* @since Envoy Common v0.1-beta * @since Envoy Common v0.1-beta
*/ */
public class GroupResizeEvent extends Event<User> { public class GroupResize extends Event<User> {
private final long groupID; private final long groupID;
private final ElementOperation operation; private final ElementOperation operation;
@ -25,7 +25,7 @@ public class GroupResizeEvent extends Event<User> {
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;
/** /**
* Initializes a {@link GroupResizeEvent} through a Contact where the name has * Initializes a {@link GroupResize} through a Contact where the name has
* already been set. * already been set.
* *
* @param user the {@link User} who wants to join or leave a group * @param user the {@link User} who wants to join or leave a group
@ -34,7 +34,7 @@ public class GroupResizeEvent extends Event<User> {
* add him to this group or remove him from it * add him to this group or remove him from it
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public GroupResizeEvent(User user, Group group, ElementOperation operation) { public GroupResize(User user, Group group, ElementOperation operation) {
super(user); super(user);
if (group.getContacts().contains(user)) { if (group.getContacts().contains(user)) {
if (operation.equals(ElementOperation.ADD)) throw new IllegalArgumentException( if (operation.equals(ElementOperation.ADD)) throw new IllegalArgumentException(
@ -61,5 +61,5 @@ public class GroupResizeEvent extends Event<User> {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public String toString() { return String.format("GroupResizeEvent[userid=%d,groupid=%d,operation=%s]", get(), groupID, operation); } public String toString() { return String.format("GroupResize[userid=%d,groupid=%d,operation=%s]", get(), groupID, operation); }
} }

View File

@ -0,0 +1,63 @@
package envoy.event;
/**
* Signifies to the client that the handshake failed for the attached
* reason.
* <p>
* Project: <strong>envoy-common</strong><br>
* File: <strong>HandshakeRejection.java</strong><br>
* Created: <strong>28 Jan 2020</strong><br>
*
* @author Kai S. K. Engelbart
* @since Envoy Common v0.3-alpha
*/
public class HandshakeRejection extends Event<String> {
/**
* Select this value if a given password hash or user name was incorrect.
*
* @since Envoy Common v0.3-alpha
*/
public static final String WRONG_PASSWORD_OR_USER = "Incorrect user name or password.";
/**
* Select this value if a given user name for a registration is already taken.
*
* @since Envoy Common v0.1-beta
*/
public static final String USERNAME_TAKEN = "Incorrect user name or password.";
/**
* Select this value if the version of the client is incompatible with the
* server.
*
* @since Envoy Common v0.1-beta
*/
public static final String WRONG_VERSION = "Incompatible client version";
/**
* Select this value if the handshake could not be completed for some different
* reason.
*
* @since Envoy Common v0.3-alpha
*/
public static final String INTERNAL_ERROR = "An internal error occured.";
private static final long serialVersionUID = 0L;
/**
* Creates an instance of {@link HandshakeRejection} with the generic
* {@link HandshakeRejection#INTERNAL_ERROR} reason.
*
* @since Envoy Common v0.3-alpha
*/
public HandshakeRejection() { super(INTERNAL_ERROR); }
/**
* Creates an instance of {@link HandshakeRejection}.
*
* @param reason the reason why the handshake was rejected
* @since Envoy Common v0.3-alpha
*/
public HandshakeRejection(String reason) { super(reason); }
}

View File

@ -1,42 +0,0 @@
package envoy.event;
/**
* Signifies to the client that the handshake failed for the attached
* reason.<br>
* <br>
* Project: <strong>envoy-common</strong><br>
* File: <strong>HandshakeRejectionEvent.java</strong><br>
* Created: <strong>28 Jan 2020</strong><br>
*
* @author Kai S. K. Engelbart
* @since Envoy Common v0.3-alpha
*/
public class HandshakeRejectionEvent extends Event<String> {
/**
* Select this value if a given password hash or user was incorrect.
*/
public static final String WRONG_PASSWORD_OR_USER = "Incorrect user name or password.";
/**
* Select this value if the handshake could not be completed for some reason.
*/
public static final String INTERNAL_ERROR = "An internal error occured.";
private static final long serialVersionUID = 0L;
/**
* Creates an instance of {@link HandshakeRejectionEvent} with an empty reason.
*
* @since Envoy Common v0.3-alpha
*/
public HandshakeRejectionEvent() { super(""); }
/**
* Creates an instance of {@link HandshakeRejectionEvent}.
*
* @param reason the reason why the handshake was rejected
* @since Envoy Common v0.3-alpha
*/
public HandshakeRejectionEvent(String reason) { super(reason); }
}

View File

@ -1,26 +1,26 @@
package envoy.event; package envoy.event;
import java.util.Date; import java.time.LocalDateTime;
import envoy.data.Message; import envoy.data.Message;
/** /**
* Project: <strong>envoy-common</strong><br> * Project: <strong>envoy-common</strong><br>
* File: <strong>MessageStatusChangeEvent.java</strong><br> * File: <strong>MessageStatusChange.java</strong><br>
* Created: <strong>6 Jan 2020</strong><br> * Created: <strong>6 Jan 2020</strong><br>
* *
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public class MessageStatusChangeEvent extends Event<Message.MessageStatus> { public class MessageStatusChange extends Event<Message.MessageStatus> {
private final long id; private final long id;
private final Date date; private final LocalDateTime date;
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;
/** /**
* Initializes a {@link MessageStatusChangeEvent}. * Initializes a {@link MessageStatusChange}.
* *
* @param id the ID of the {@link Message} this event is related to * @param id the ID of the {@link Message} this event is related to
* @param status the status of the {@link Message} this event is related * @param status the status of the {@link Message} this event is related
@ -28,19 +28,19 @@ public class MessageStatusChangeEvent extends Event<Message.MessageStatus> {
* @param date the date at which the MessageStatus change occurred * @param date the date at which the MessageStatus change occurred
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public MessageStatusChangeEvent(long id, Message.MessageStatus status, Date date) { public MessageStatusChange(long id, Message.MessageStatus status, LocalDateTime date) {
super(status); super(status);
this.id = id; this.id = id;
this.date = date; this.date = date;
} }
/** /**
* Initializes a {@link MessageStatusChangeEvent} through a message. * Initializes a {@link MessageStatusChange} through a message.
* *
* @param message the message from which to build the event * @param message the message from which to build the event
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public MessageStatusChangeEvent(Message message) { this(message.getID(), message.getStatus(), new Date()); } public MessageStatusChange(Message message) { this(message.getID(), message.getStatus(), LocalDateTime.now()); }
/** /**
* @return the ID of the {@link Message} this event is related to * @return the ID of the {@link Message} this event is related to
@ -52,8 +52,8 @@ public class MessageStatusChangeEvent extends Event<Message.MessageStatus> {
* @return the date at which the status change occurred * @return the date at which the status change occurred
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public Date getDate() { return date; } public LocalDateTime getDate() { return date; }
@Override @Override
public String toString() { return String.format("MessageStatusChangeEvent[id=%d,status=%s,date=%s]", id, value, date); } public String toString() { return String.format("MessageStatusChange[id=%d,status=%s,date=%s]", id, value, date); }
} }

View File

@ -8,38 +8,38 @@ import envoy.data.Contact;
* b) another user of this users name change. * b) another user of this users name change.
* *
* Project: <strong>envoy-common</strong><br> * Project: <strong>envoy-common</strong><br>
* File: <strong>NameChangeEvent.java</strong><br> * File: <strong>NameChange.java</strong><br>
* Created: <strong>25 Mar 2020</strong><br> * Created: <strong>25 Mar 2020</strong><br>
* *
* @author Leon Hofmeister * @author Leon Hofmeister
* @since Envoy Common v0.1-beta * @since Envoy Common v0.1-beta
*/ */
public class NameChangeEvent extends Event<String> { public class NameChange extends Event<String> {
private final long id; private final long id;
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;
/** /**
* Creates a new {@link NameChangeEvent} for a user or a group. * Creates a new {@link NameChange} for a user or a group.
* *
* @param contactID the id of the {@link Contact} who wishes to change his name * @param contactID the id of the {@link Contact} who wishes to change his name
* @param newName the new name of this contact * @param newName the new name of this contact
* @since Envoy Common v0.1-beta * @since Envoy Common v0.1-beta
*/ */
public NameChangeEvent(long contactID, String newName) { public NameChange(long contactID, String newName) {
super(newName); super(newName);
id = contactID; id = contactID;
} }
/** /**
* Initializes a {@link NameChangeEvent} through a Contact where the name has * Initializes a {@link NameChange} through a Contact where the name has
* already been set. * already been set.
* *
* @param contact the contact whose name was updated * @param contact the contact whose name was updated
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public NameChangeEvent(Contact contact) { this(contact.getID(), contact.getName()); } public NameChange(Contact contact) { this(contact.getID(), contact.getName()); }
/** /**
* @return the ID of the {@link Contact} this event is related to * @return the ID of the {@link Contact} this event is related to
@ -48,5 +48,5 @@ public class NameChangeEvent extends Event<String> {
public long getID() { return id; } public long getID() { return id; }
@Override @Override
public String toString() { return String.format("NameChangeEvent[id=%d,name=%s]", id, value); } public String toString() { return String.format("NameChange[id=%d,name=%s]", id, value); }
} }

View File

@ -5,38 +5,38 @@ import envoy.data.User.UserStatus;
/** /**
* Project: <strong>envoy-common</strong><br> * Project: <strong>envoy-common</strong><br>
* File: <strong>UserStatusChangeEvent.java</strong><br> * File: <strong>UserStatusChange.java</strong><br>
* Created: <strong>1 Feb 2020</strong><br> * Created: <strong>1 Feb 2020</strong><br>
* *
* @author Leon Hofmeister * @author Leon Hofmeister
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public class UserStatusChangeEvent extends Event<UserStatus> { public class UserStatusChange extends Event<UserStatus> {
private final long id; private final long id;
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;
/** /**
* Initializes a {@link UserStatusChangeEvent}. * Initializes a {@link UserStatusChange}.
* *
* @param id the ID of the {@link User} this event is related to * @param id the ID of the {@link User} this event is related to
* @param status the status of the {@link User} this event is related * @param status the status of the {@link User} this event is related
* to * to
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public UserStatusChangeEvent(long id, User.UserStatus status) { public UserStatusChange(long id, User.UserStatus status) {
super(status); super(status);
this.id = id; this.id = id;
} }
/** /**
* Initializes a {@link UserStatusChangeEvent} through a User. * Initializes a {@link UserStatusChange} through a User.
* *
* @param user the User from which to build the event * @param user the User from which to build the event
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public UserStatusChangeEvent(User user) { this(user.getID(), user.getStatus()); } public UserStatusChange(User user) { this(user.getID(), user.getStatus()); }
/** /**
* @return the ID of the {@link User} this event is related to * @return the ID of the {@link User} this event is related to
@ -45,5 +45,5 @@ public class UserStatusChangeEvent extends Event<UserStatus> {
public long getID() { return id; } public long getID() { return id; }
@Override @Override
public String toString() { return String.format("UserStatusChangeEvent[id=%d,status=%s]", id, value); } public String toString() { return String.format("UserStatusChange[id=%d,status=%s]", id, value); }
} }

View File

@ -8,26 +8,26 @@ import envoy.event.Event;
* Signifies the modification of a contact list.<br> * Signifies the modification of a contact list.<br>
* <br> * <br>
* Project: <strong>envoy-common</strong><br> * Project: <strong>envoy-common</strong><br>
* File: <strong>ContactOperationEvent.java</strong><br> * File: <strong>ContactOperation.java</strong><br>
* Created: <strong>05.02.2020</strong><br> * Created: <strong>05.02.2020</strong><br>
* *
* @author Maximilian K&auml;fer * @author Maximilian K&auml;fer
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public class ContactOperationEvent extends Event<Contact> { public class ContactOperation extends Event<Contact> {
private final ElementOperation operationType; private final ElementOperation operationType;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* Initializes a {@link ContactOperationEvent}. * Initializes a {@link ContactOperation}.
* *
* @param contact the user on which the operation is performed * @param contact the user on which the operation is performed
* @param operationType the type of operation to perform * @param operationType the type of operation to perform
* @since Envoy Common v0.2-alpha * @since Envoy Common v0.2-alpha
*/ */
public ContactOperationEvent(Contact contact, ElementOperation operationType) { public ContactOperation(Contact contact, ElementOperation operationType) {
super(contact); super(contact);
this.operationType = operationType; this.operationType = operationType;
} }