82 lines
2.1 KiB
Java
82 lines
2.1 KiB
Java
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<User> 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<br>
|
|
* <strong>that have not yet been notified of its
|
|
* deletion</strong>
|
|
* @since Envoy Server v0.3-beta
|
|
*/
|
|
public MessageDeletion(long messageID, Set<User> 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<User> getRecipientsToInform() { return recipientsToInform; }
|
|
|
|
/**
|
|
* @param recipientsToInform the recipients that have yet to be informed
|
|
* @since Envoy Server v0.3-beta
|
|
*/
|
|
public void setRecipientsToInform(Set<User> 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<User> users) { recipientsToInform.removeAll(users); }
|
|
}
|