package envoy.server.data; import java.util.*; import javax.persistence.*; /** * Defines a message that has been deleted. * * @author Leon Hofmeister * @since Envoy Server v0.3-beta */ @Entity @Table(name = "deletionEvents") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public final class MessageDeletion { @Id @GeneratedValue protected long messageID; @ManyToOne(targetEntity = User.class) protected Set recipientsToInform; /** * Creates an instance of {@code DeletionEvent}. * * @since Envoy Server v0.3-beta */ public MessageDeletion() {} /** * Creates an instance of {@code MessageDeletion}. * * @param messageID the ID of the message * @param recipientsToInform the recipientsToInform of the message
* that have not yet been notified of its * deletion * @since Envoy Server v0.3-beta */ public MessageDeletion(long messageID, Set recipientsToInform) { this.messageID = messageID; this.recipientsToInform = recipientsToInform; } /** * @return the messageID * @since Envoy Server v0.3-beta */ public long getMessageID() { return messageID; } /** * @param messageID the messageID to set * @since Envoy Server v0.3-beta */ public void setMessageID(long messageID) { this.messageID = messageID; } /** * @return the recipients that have yet to be informed * @since Envoy Server v0.3-beta */ public Set getRecipientsToInform() { return recipientsToInform; } /** * @param recipientsToInform the recipients that have yet to be informed * @since Envoy Server v0.3-beta */ public void setRecipientsToInform(Set recipientsToInform) { this.recipientsToInform = recipientsToInform; } /** * @param user the user who has been informed of the message deletion * @since Envoy Server v0.3-beta */ public void recipientInformed(User user) { recipientsToInform.remove(user); } /** * @param users the users that have been informed of the message deletion * @since Envoy Server v0.3-beta */ public void recipientInformed(Collection users) { recipientsToInform.removeAll(users); } }