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/server/src/main/java/envoy/server/data/MessageDeletion.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); }
}