87 lines
1.6 KiB
Java
87 lines
1.6 KiB
Java
package org.gcube.gcat.social;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.List;
|
|
|
|
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
|
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
|
import org.gcube.com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
|
/**
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
*/
|
|
public class Message {
|
|
|
|
public class Recipient {
|
|
|
|
String id;
|
|
|
|
public Recipient(String id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(String id) {
|
|
this.id = id;
|
|
}
|
|
|
|
}
|
|
|
|
@JsonProperty(value = "body")
|
|
protected String message;
|
|
@JsonProperty(value = "subject")
|
|
protected String subject;
|
|
@JsonIgnore
|
|
protected Collection<String> users;
|
|
|
|
public String getMessage() {
|
|
return message;
|
|
}
|
|
|
|
public void setMessage(String message) {
|
|
this.message = message;
|
|
}
|
|
|
|
public String getSubject() {
|
|
return subject;
|
|
}
|
|
|
|
public void setSubject(String subject) {
|
|
this.subject = subject;
|
|
}
|
|
|
|
@JsonIgnore
|
|
public Collection<String> getUsers() {
|
|
return users;
|
|
}
|
|
|
|
@JsonIgnore
|
|
public void setUsers(Collection<String> users) {
|
|
this.users = users;
|
|
}
|
|
|
|
@JsonIgnore
|
|
public void addUser(String user) {
|
|
this.users.add(user);
|
|
}
|
|
|
|
@JsonGetter(value = "recipients")
|
|
public List<Recipient> getRecipients() {
|
|
List<Recipient> recipients = new ArrayList<>();
|
|
for(String username : users) {
|
|
recipients.add(new Recipient(username));
|
|
}
|
|
return recipients;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Message [message=" + message + ", subject=" + subject + ", users=" + users + "]";
|
|
}
|
|
|
|
}
|