Apply suggestions by @kske

This commit is contained in:
2020-10-27 23:01:44 +01:00
parent d4c7813c97
commit 7a883861be
18 changed files with 85 additions and 173 deletions

View File

@ -1,61 +0,0 @@
package envoy.data;
import java.io.Serializable;
import java.util.Objects;
/**
* Enables checking for the server whether the client is really who he is supposed to be.
*
* @author Leon Hofmeister
* @param <T> the type of object to be sent
* @since Envoy Common v0.3-beta
*/
public final class AuthenticatedRequest<T extends Serializable> implements Serializable {
private final T request;
private final long userID;
private static final long serialVersionUID = 1L;
/**
* @param request the actual object that should be sent
* @param userID the ID of the currently logged in user
* @since Envoy Common v0.3-beta
*/
public AuthenticatedRequest(T request, long userID) {
this.request = Objects.requireNonNull(request);
this.userID = userID;
}
/**
* @return the request
* @since Envoy Common v0.3-beta
*/
public T getRequest() { return request; }
/**
* @return the userID
* @since Envoy Common v0.3-beta
*/
public long getUserID() { return userID; }
@Override
public int hashCode() {
return Objects.hash(request, userID);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!(obj instanceof AuthenticatedRequest))
return false;
AuthenticatedRequest<?> other = (AuthenticatedRequest<?>) obj;
return userID == other.userID;
}
@Override
public String toString() {
return "AuthenticatedRequest [request=" + request + ", userID=" + userID + "]";
}
}

View File

@ -30,7 +30,7 @@ public final class GroupMessageStatusChange extends MessageStatusChange {
}
/**
* @return the memberID which the user who sends this event has
* @return the ID of the sender of this event
* @since Envoy Common v0.1-beta
*/
public long getMemberID() { return memberID; }

View File

@ -8,8 +8,6 @@ package envoy.event;
*/
public final class IsTyping extends Event<Long> {
private final long destinationID;
private static final long serialVersionUID = 1L;
/**
@ -22,20 +20,13 @@ public final class IsTyping extends Event<Long> {
public static final int millisecondsActive = 3500;
/**
* Creates a new {@code IsTyping} event with originator and recipient.
* Creates a new {@code IsTyping}. The client will only send the contact that should receive
* this event. The server will send the id of the contact who sent this event.
*
* @param sourceID the ID of the originator
* @param destinationID the ID of the contact the user wrote to
* @param id the ID of the recipient (client)/ originator(server)
* @since Envoy Common v0.2-beta
*/
public IsTyping(long sourceID, long destinationID) {
super(sourceID);
this.destinationID = destinationID;
public IsTyping(long id) {
super(id);
}
/**
* @return the ID of the contact in whose chat the user typed something
* @since Envoy Common v0.2-beta
*/
public long getDestinationID() { return destinationID; }
}

View File

@ -2,37 +2,26 @@ package envoy.event;
import java.util.Objects;
import envoy.data.Contact;
/**
* @author Leon Hofmeister
* @since Envoy Common v0.2-beta
*/
public final class PasswordChangeRequest extends Event<String> {
private final long id;
private final String oldPassword;
private final String oldPassword;
private static final long serialVersionUID = 0L;
/**
* @param newPassword the new password of that user
* @param oldPassword the old password of that user
* @param userID the ID of the user who wants to change his password
* @since Envoy Common v0.2-beta
*/
public PasswordChangeRequest(String newPassword, String oldPassword, long userID) {
public PasswordChangeRequest(String newPassword, String oldPassword) {
super(newPassword);
this.oldPassword = Objects.requireNonNull(oldPassword);
id = userID;
this.oldPassword = Objects.requireNonNull(oldPassword);
}
/**
* @return the ID of the {@link Contact} this event is related to
* @since Envoy Common v0.2-alpha
*/
public long getID() { return id; }
/**
* @return the old password of the underlying user
* @since Envoy Common v0.2-beta
@ -41,6 +30,6 @@ public final class PasswordChangeRequest extends Event<String> {
@Override
public String toString() {
return "PasswordChangeRequest[id=" + id + "]";
return "PasswordChangeRequest[]";
}
}

View File

@ -6,23 +6,13 @@ package envoy.event;
*/
public final class ProfilePicChange extends Event<byte[]> {
private final long id;
private static final long serialVersionUID = 0L;
/**
* @param value the byte[] of the new image
* @param userID the ID of the user who changed his profile pic
* @param value the byte[] of the new image
* @since Envoy Common v0.2-beta
*/
public ProfilePicChange(byte[] value, long userID) {
public ProfilePicChange(byte[] value) {
super(value);
id = userID;
}
/**
* @return the ID of the user changing his profile pic
* @since Envoy Common v0.2-beta
*/
public long getId() { return id; }
}