This repository has been archived on 2021-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
envoy/src/main/java/envoy/server/data/Message.java

82 lines
2.3 KiB
Java
Raw Normal View History

2020-01-02 17:50:56 +01:00
package envoy.server.data;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import envoy.data.MessageBuilder;
/**
* Project: <strong>envoy-server-standalone</strong><br>
* File: <strong>Message.java</strong><br>
* Created: <strong>02.01.2020</strong><br>
*
* @author Kai S. K. Engelbart
* @since Envoy Server Standalone v0.1-alpha
*/
@Entity
public class Message {
@Id
private long id;
private User sender, recipient;
@Temporal(TemporalType.TIMESTAMP)
private Date creationDate;
@Temporal(TemporalType.TIMESTAMP)
private Date receivedDate;
@Temporal(TemporalType.TIMESTAMP)
private Date readDate;
private envoy.data.Message.MessageStatus status;
private String text;
private byte[] attachment;
public Message() {}
// TODO: everything except ID
public Message(envoy.data.Message message) { id = message.getId(); }
public envoy.data.Message toCommonMessage() {
// TODO: Attachment, dates
return new MessageBuilder(sender.getId(), recipient.getId()).setText(text).setDate(creationDate).setStatus(status).build();
}
public long getId() { return id; }
public void setId(long id) { this.id = id; }
public User getSender() { return sender; }
public void setSender(User sender) { this.sender = sender; }
public User getRecipient() { return recipient; }
public void setRecipient(User recipient) { this.recipient = recipient; }
public Date getCreationDate() { return creationDate; }
public void setCreationDate(Date creationDate) { this.creationDate = creationDate; }
public Date getReceivedDate() { return receivedDate; }
public void setReceivedDate(Date receivedDate) { this.receivedDate = receivedDate; }
public Date getReadDate() { return readDate; }
public void setReadDate(Date readDate) { this.readDate = readDate; }
public envoy.data.Message.MessageStatus getStatus() { return status; }
public void setStatus(envoy.data.Message.MessageStatus status) { this.status = status; }
public String getText() { return text; }
public void setText(String text) { this.text = text; }
public byte[] getAttachment() { return attachment; }
public void setAttachment(byte[] attachment) { this.attachment = attachment; }
}