Fixed member orders in some classes

This commit is contained in:
Kai S. K. Engelbart 2019-12-31 11:20:35 +02:00
parent b66900c864
commit 757f661e08
3 changed files with 48 additions and 48 deletions

View File

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

View File

@ -83,6 +83,35 @@ public class Message implements Serializable {
this.status = status;
}
/**
* Changes the current {@link MessageStatus} to the next logical status.<br>
* <br>
* The underlying order is as follows:
* <ol>
* <li>{@link MessageStatus#WAITING}
* <li>{@link MessageStatus#SENT}
* <li>{@link MessageStatus#RECEIVED}
* <li>{@link MessageStatus#READ}
* </ol>
*
* @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.<br>
* <br>
* The underlying order is as follows:
* <ol>
* <li>{@link MessageStatus#WAITING}
* <li>{@link MessageStatus#SENT}
* <li>{@link MessageStatus#RECEIVED}
* <li>{@link MessageStatus#READ}
* </ol>
*
* @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);
}
}

View File

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