From ba28b3aac6b26798b5b2980734acdb88625104af Mon Sep 17 00:00:00 2001 From: kske Date: Tue, 31 Dec 2019 11:20:35 +0200 Subject: [PATCH] Fixed member orders in some classes --- .../java/envoy/data/LoginCredentials.java | 28 ++++----- src/main/java/envoy/data/Message.java | 58 +++++++++---------- src/main/java/envoy/data/User.java | 10 ++-- 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/main/java/envoy/data/LoginCredentials.java b/src/main/java/envoy/data/LoginCredentials.java index 7166ad0..58d14d4 100644 --- a/src/main/java/envoy/data/LoginCredentials.java +++ b/src/main/java/envoy/data/LoginCredentials.java @@ -17,8 +17,8 @@ import java.util.Formatter; */ public class LoginCredentials implements Serializable { - private final String name; - private final byte[] passwordHash; + private final String name; + private final byte[] passwordHash; private static final long serialVersionUID = -7395245059059523314L; @@ -35,18 +35,6 @@ public class LoginCredentials implements Serializable { passwordHash = getSha256(toByteArray(password)); } - /** - * @return the name of the user performing the login - * @since Envoy Common v0.2-alpha - */ - public String getName() { return name; } - - /** - * @return the password hash of the user performing the login - * @since Envoy Common v0.2-alpha - */ - public byte[] getPasswordHash() { return passwordHash; } - private byte[] getSha256(byte[] input) throws NoSuchAlgorithmException { return MessageDigest.getInstance("SHA-256").digest(input); } private byte[] toByteArray(char[] chars) { @@ -67,4 +55,16 @@ public class LoginCredentials implements Serializable { return form.format("]").toString(); } } + + /** + * @return the name of the user performing the login + * @since Envoy Common v0.2-alpha + */ + public String getName() { return name; } + + /** + * @return the password hash of the user performing the login + * @since Envoy Common v0.2-alpha + */ + public byte[] getPasswordHash() { return passwordHash; } } \ No newline at end of file diff --git a/src/main/java/envoy/data/Message.java b/src/main/java/envoy/data/Message.java index 8e676a6..b2f6545 100644 --- a/src/main/java/envoy/data/Message.java +++ b/src/main/java/envoy/data/Message.java @@ -83,6 +83,35 @@ public class Message implements Serializable { this.status = status; } + /** + * Changes the current {@link MessageStatus} to the next logical status.
+ *
+ * The underlying order is as follows: + *
    + *
  1. {@link MessageStatus#WAITING} + *
  2. {@link MessageStatus#SENT} + *
  3. {@link MessageStatus#RECEIVED} + *
  4. {@link MessageStatus#READ} + *
+ * + * @since Envoy Common v0.2-alpha + */ + public void nextStatus() { + if (status == MessageStatus.READ) throw new IllegalStateException("Message status READ is already reached"); + status = MessageStatus.values()[status.ordinal() + 1]; + } + + @Override + public String toString() { + return String.format("TextMessage[id=%d,sender=%s,recipient=%s,date=%s,status=%s,text=%s]", + id, + sender, + recipient, + new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(date), + status, + text); + } + /** * @return the ID of this message * @since Envoy Common v0.2-alpha @@ -124,33 +153,4 @@ public class Message implements Serializable { * @since Envoy Common v0.2-alpha */ public MessageStatus getStatus() { return status; } - - /** - * Changes the current {@link MessageStatus} to the next logical status.
- *
- * The underlying order is as follows: - *
    - *
  1. {@link MessageStatus#WAITING} - *
  2. {@link MessageStatus#SENT} - *
  3. {@link MessageStatus#RECEIVED} - *
  4. {@link MessageStatus#READ} - *
- * - * @since Envoy Common v0.2-alpha - */ - public void nextStatus() { - if (status == MessageStatus.READ) throw new IllegalStateException("Message status READ is already reached"); - status = MessageStatus.values()[status.ordinal() + 1]; - } - - @Override - public String toString() { - return String.format("TextMessage[id=%d,sender=%s,recipient=%s,date=%s,status=%s,text=%s]", - id, - sender, - recipient, - new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(date), - status, - text); - } } \ No newline at end of file diff --git a/src/main/java/envoy/data/User.java b/src/main/java/envoy/data/User.java index c49d361..de29fc4 100644 --- a/src/main/java/envoy/data/User.java +++ b/src/main/java/envoy/data/User.java @@ -44,8 +44,8 @@ public class User implements Serializable { OFFLINE; } - private final long id; - private final String name; + private final long id; + private final String name; private UserStatus status; @@ -65,6 +65,9 @@ public class User implements Serializable { status = UserStatus.OFFLINE; } + @Override + public String toString() { return String.format("User[id=%d,name=%s,status=%s]", id, name, status); } + /** * @return the ID of this {@link User} * @since Envoy Client v0.2-alpha @@ -90,7 +93,4 @@ public class User implements Serializable { * @since Envoy Client v0.2-alpha */ public void setStatus(UserStatus status) { this.status = status; } - - @Override - public String toString() { return String.format("User[id=%d,name=%s,status=%s]", id, name, status); } } \ No newline at end of file