Storing sender and recipient IDs in message, added contact list to User

This commit is contained in:
Kai S. K. Engelbart 2019-12-31 16:38:07 +02:00
parent ba28b3aac6
commit 565175cc67
2 changed files with 28 additions and 4 deletions

View File

@ -48,8 +48,8 @@ public class Message implements Serializable {
READ
}
private final long id;
private final User sender, recipient;
private final long id, senderId, recipientId;
private final transient User sender, recipient;
private final Date date;
private final String text;
private final MessageAttachment<?> attachment;
@ -81,6 +81,9 @@ public class Message implements Serializable {
this.text = text;
this.attachment = attachment;
this.status = status;
senderId = sender.getId();
recipientId = recipient.getId();
}
/**
@ -124,12 +127,24 @@ public class Message implements Serializable {
*/
public User getSender() { return sender; }
/**
* @return the sender ID of this message
* @since Envoy Common v0.2-alpha
*/
public long getSenderId() { return senderId; }
/**
* @return the recipient of this message
* @since Envoy Common v0.2-alpha
*/
public User getRecipient() { return recipient; }
/**
* @return the recipient ID of this message
* @since Envoy Common v0.2-alpha
*/
public long getRecipientId() { return recipientId; }
/**
* @return the date at which this message was created
* @since Envoy Common v0.2-alpha

View File

@ -1,6 +1,8 @@
package envoy.data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* Represents a unique user with a unique, numeric ID, a name and a current
@ -44,8 +46,9 @@ public class User implements Serializable {
OFFLINE;
}
private final long id;
private final String name;
private final long id;
private final String name;
private final List<User> contacts = new ArrayList<>();
private UserStatus status;
@ -80,6 +83,12 @@ public class User implements Serializable {
*/
public String getName() { return name; }
/**
* @return a list of all users this user can send messages to
* @since Envoy Client v0.2-alpha
*/
public List<User> getContacts() { return contacts; }
/**
* @return the current status of this user
* @since Envoy Client v0.2-alpha