Project

General

Profile

1
package eu.dnetlib.domain.functionality;
2

    
3
import java.util.Date;
4

    
5
/**
6
 * This class represents a result of a notification event.
7
 * @author thanos@di.uoa.gr
8
 * @see eu.dnetlib.api.functionality.NotificationService
9
 * @see eu.dnetlib.functionality.notification.executor.NotificationQueryExecutor
10
 * @see NotificationQuery
11
 * @see NotificationSchedule
12
 * @see NotificationEvent
13
 * @see NotificationSubscription
14
 *
15
 */
16
public class NotificationResult implements Comparable<NotificationResult> {
17
	private String queryId;
18
	private Date date;
19
	private String resultId;
20
	private String name;
21
	private int value;
22
	
23
	/**
24
	 * Construct a new notification result.
25
	 * @param queryId the unique identifier of the query of the event of this result
26
	 * @param date the date of the event of this result
27
	 * @param resultId the unique identifier of this result
28
	 * @param name the name of this result
29
	 * @param value the value of this result
30
	 */
31
	public NotificationResult(final String queryId, final Date date, final String resultId, final String name, final int value) {
32
		this.queryId = queryId;
33
		this.date = date;
34
		this.resultId = resultId;
35
		this.name = name;
36
		this.value = value;
37
	}
38
	
39
	/**
40
	 * Construct a new notification result with query identifier, date, result identifier and result name set to null and value set to zero.
41
	 */
42
	public NotificationResult() {
43
		this(null, null, null, null, 0);
44
	}
45
	
46
	/**
47
	 * Get the query of the event of this result.
48
	 * @return the unique identifier of the query of the event of this result
49
	 */
50
	public String getQueryId() {
51
		return queryId;
52
	}
53
	
54
	/**
55
	 * Set the query of the event of this result.
56
	 * @param queryId the unique identifier of the query of the event of this result
57
	 */
58
	public void setQueryId(final String queryId) {
59
		this.queryId = queryId;
60
	}
61

    
62
	/**
63
	 * Get the date of the event of this result.
64
	 * @return the date of the event of this result
65
	 */
66
	public Date getDate() {
67
		return date;
68
	}
69
	
70
	/**
71
	 * Set the date of the event of this result.
72
	 * @param date the date of the event of this result
73
	 */
74
	public void setDate(final Date date) {
75
		this.date = date;
76
	}
77
	
78
	/**
79
	 * Get the result identifier.
80
	 * @return the unique identifier of this result
81
	 */
82
	public String getResultId() {
83
		return resultId;
84
	}
85
	
86
	/**
87
	 * Set the result identifier.
88
	 * @param resultId the unique identifier of this result
89
	 */
90
	public void setResultId(final String resultId) {
91
		this.resultId = resultId;
92
	}
93
	
94
	/**
95
	 * Get the name.
96
	 * @return the name of this result
97
	 */
98
	public String getName() {
99
		return name;
100
	}
101
	
102
	/**
103
	 * Set the name of this result.
104
	 * @param name the name of this result
105
	 */
106
	public void setName(final String name) {
107
		this.name = name;
108
	}
109
		
110
	/**
111
	 * Get the value of this result.
112
	 * @return the value of this result
113
	 */
114
	public int getValue() {
115
		return value;
116
	}
117
		
118
	/**
119
	 * Set the value of this result.
120
	 * @param value the value of this result
121
	 */
122
	public void setValue(final int value) {
123
		this.value = value;
124
	}
125
	
126
	@Override
127
	public int compareTo(final NotificationResult result) {
128
		final int queryIdComparison = queryId.compareTo(result.queryId);
129
		final int dateComparison = date.compareTo(result.date);
130
		final int resultIdComparison = resultId.compareTo(result.resultId);
131
		return (queryIdComparison == 0) ? ((dateComparison == 0) ? resultIdComparison : dateComparison) : queryIdComparison;
132
	}
133
	
134
	@Override
135
	public boolean equals(final Object object) {
136
		if (!(object instanceof NotificationResult))
137
			return false;
138
		final NotificationResult result = (NotificationResult) object;
139
		return ((queryId == null) ? (result.queryId == null) : queryId.equals(result.queryId)) && ((date == null) ? (result.date == null) : date.equals(result.date)) &&
140
				((resultId == null) ? (result.resultId == null) : resultId.equals(result.resultId));
141
	}
142
	
143
	@Override
144
	public int hashCode() {
145
		return ((queryId == null) ? 0 : queryId.hashCode()) + ((date == null) ? 0 : date.hashCode()) + ((resultId == null) ? 0 : resultId.hashCode());
146
	}
147
	
148
	@Override
149
	public String toString() {
150
		return "(query: " + queryId + ", date: " + date + ", result: " + resultId + ")";
151
	}
152
}
(26-26/59)