Fixed member orders in some classes
This commit is contained in:
parent
1b4c2c1fb9
commit
ba28b3aac6
@ -17,8 +17,8 @@ import java.util.Formatter;
|
|||||||
*/
|
*/
|
||||||
public class LoginCredentials implements Serializable {
|
public class LoginCredentials implements Serializable {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final byte[] passwordHash;
|
private final byte[] passwordHash;
|
||||||
|
|
||||||
private static final long serialVersionUID = -7395245059059523314L;
|
private static final long serialVersionUID = -7395245059059523314L;
|
||||||
|
|
||||||
@ -35,18 +35,6 @@ public class LoginCredentials implements Serializable {
|
|||||||
passwordHash = getSha256(toByteArray(password));
|
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[] getSha256(byte[] input) throws NoSuchAlgorithmException { return MessageDigest.getInstance("SHA-256").digest(input); }
|
||||||
|
|
||||||
private byte[] toByteArray(char[] chars) {
|
private byte[] toByteArray(char[] chars) {
|
||||||
@ -67,4 +55,16 @@ public class LoginCredentials implements Serializable {
|
|||||||
return form.format("]").toString();
|
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; }
|
||||||
}
|
}
|
@ -83,6 +83,35 @@ public class Message implements Serializable {
|
|||||||
this.status = status;
|
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
|
* @return the ID of this message
|
||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
@ -124,33 +153,4 @@ public class Message implements Serializable {
|
|||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
*/
|
*/
|
||||||
public MessageStatus getStatus() { return status; }
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -44,8 +44,8 @@ public class User implements Serializable {
|
|||||||
OFFLINE;
|
OFFLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final long id;
|
private final long id;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
private UserStatus status;
|
private UserStatus status;
|
||||||
|
|
||||||
@ -65,6 +65,9 @@ public class User implements Serializable {
|
|||||||
status = UserStatus.OFFLINE;
|
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}
|
* @return the ID of this {@link User}
|
||||||
* @since Envoy Client v0.2-alpha
|
* @since Envoy Client v0.2-alpha
|
||||||
@ -90,7 +93,4 @@ public class User implements Serializable {
|
|||||||
* @since Envoy Client v0.2-alpha
|
* @since Envoy Client v0.2-alpha
|
||||||
*/
|
*/
|
||||||
public void setStatus(UserStatus status) { this.status = status; }
|
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); }
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user