Project

General

Profile

1
package eu.dnetlib.domain.functionality;
2

    
3
import java.net.URL;
4

    
5
/**
6
 * This class represents a template for alert messages.
7
 * @author thanos
8
 * @see eu.dnetlib.api.functionality.AlertService
9
 * @see eu.dnetlib.functionality.alert.alerter.Alerter
10
 * @see AlertTopic
11
 * @see AlertSubscription
12
 *
13
 */
14
public class AlertTemplate implements Comparable<AlertTemplate> {
15
	private String templateId;
16
	private String title;
17
	private String message;
18
	private URL link;
19
	
20
	/**
21
	 * Construct a new alert template.
22
	 * @param templateId the unique identifier of this template
23
	 * @param title the title of the alerts generated by this template
24
	 * @param message the message of the alerts generated by this template
25
	 * @param link the link of the alerts generated by this template
26
	 */
27
	public AlertTemplate(final String templateId, final String title, final String message, final URL link) {
28
		this.templateId = templateId;
29
		this.title = title;
30
		this.message = message;
31
		this.link = link;
32
	}
33
	
34
	/**
35
	 * Construct a new alert template with template identifier, title, message and link set to null.
36
	 */
37
	public AlertTemplate() {
38
		this(null, null, null, null);
39
	}
40

    
41
	/**
42
	 * Get the unique identifier of this template.
43
	 * @return the unique identifier of this template
44
	 */
45
	public String getTemplateId() {
46
		return templateId;
47
	}
48
	
49
	/**
50
	 * Set the unique identifier of this template.
51
	 * @param templateId the unique identifier of this template
52
	 */
53
	public void setTemplateId(final String templateId) {
54
		this.templateId = templateId;
55
	}
56
	
57
	/**
58
	 * Get the title.
59
	 * @return the title of this template
60
	 */
61
	public String getTitle() {
62
		return title;
63
	}
64
	
65
	/**
66
	 * Set the title.
67
	 * @param title the title of this template
68
	 */
69
	public void setTitle(final String title) {
70
		this.title = title;
71
	}
72
	
73
	/**
74
	 * Get the message.
75
	 * @return the message of this template
76
	 */
77
	public String getMessage() {
78
		return message;
79
	}
80
	
81
	/**
82
	 * Set the message.
83
	 * @param message the message of this template
84
	 */
85
	public void setMessage(final String message) {
86
		this.message = message;
87
	}
88
	
89
	/**
90
	 * Get the link.
91
	 * @return the link of this template
92
	 */
93
	public URL getLink() {
94
		return link;
95
	}
96
	
97
	/**
98
	 * Set the link.
99
	 * @param link the link of this template
100
	 */
101
	public void setLink(final URL link) {
102
		this.link = link;
103
	}
104
	
105
	@Override
106
	public int compareTo(final AlertTemplate template) {
107
		return templateId.compareTo(template.templateId);
108
	}
109
	
110
	@Override
111
	public boolean equals(final Object object) {
112
		if (!(object instanceof AlertTemplate))
113
			return false;
114
		final AlertTemplate template = (AlertTemplate) object;
115
		return (templateId == null) ? (template.templateId == null) : templateId.equals(template.templateId);
116
	}
117
	
118
	@Override
119
	public int hashCode() {
120
		return (templateId == null) ? 0 : templateId.hashCode();
121
	}
122
	
123
	@Override
124
	public String toString() {
125
		return templateId;
126
	}
127
}
(2-2/59)