1
|
package eu.dnetlib.enabling.tools.blackboard;
|
2
|
|
3
|
import java.util.ArrayList;
|
4
|
import java.util.List;
|
5
|
|
6
|
import javax.xml.bind.annotation.XmlAccessType;
|
7
|
import javax.xml.bind.annotation.XmlAccessorType;
|
8
|
import javax.xml.bind.annotation.XmlAttribute;
|
9
|
import javax.xml.bind.annotation.XmlElement;
|
10
|
import javax.xml.bind.annotation.XmlRootElement;
|
11
|
|
12
|
import org.apache.commons.lang3.builder.EqualsBuilder;
|
13
|
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
14
|
|
15
|
/**
|
16
|
* standard serialization of the blackboard message.
|
17
|
*
|
18
|
* @author marko
|
19
|
*
|
20
|
*/
|
21
|
@XmlRootElement(namespace = "", name = "MESSAGE")
|
22
|
@XmlAccessorType(XmlAccessType.NONE)
|
23
|
public class BlackboardMessageImpl implements BlackboardMessage {
|
24
|
|
25
|
/**
|
26
|
* hash seed.
|
27
|
*/
|
28
|
private static final int HASH_SEED_2 = 63;
|
29
|
|
30
|
/**
|
31
|
* hash seed.
|
32
|
*/
|
33
|
private static final int HASH_SEED = 13;
|
34
|
|
35
|
/**
|
36
|
* blackboard message timestamp.
|
37
|
*/
|
38
|
@XmlAttribute
|
39
|
private String date;
|
40
|
|
41
|
/**
|
42
|
* blackboard message identifier.
|
43
|
*/
|
44
|
@XmlAttribute
|
45
|
private String id; // NOPMD
|
46
|
|
47
|
/**
|
48
|
* blackboard message action name.
|
49
|
*/
|
50
|
@XmlElement(name = "ACTION", required = true)
|
51
|
private String action;
|
52
|
|
53
|
/**
|
54
|
* blackboard message parameters (key/value).
|
55
|
*/
|
56
|
@XmlElement(name = "PARAMETER", type = BlackboardParameterImpl.class)
|
57
|
private List<BlackboardParameter> parameters = new ArrayList<BlackboardParameter>();
|
58
|
|
59
|
/**
|
60
|
* the status of the action described by this message.
|
61
|
*/
|
62
|
@XmlElement(name = "ACTION_STATUS", required = true)
|
63
|
private ActionStatus actionStatus;
|
64
|
|
65
|
/**
|
66
|
* {@inheritDoc}
|
67
|
*
|
68
|
* @see java.lang.Object#equals(java.lang.Object)
|
69
|
*/
|
70
|
@Override
|
71
|
public boolean equals(final Object obj) {
|
72
|
if (!(obj instanceof BlackboardMessage))
|
73
|
return false;
|
74
|
|
75
|
if (this == obj)
|
76
|
return true;
|
77
|
|
78
|
final BlackboardMessage rhs = (BlackboardMessage) obj;
|
79
|
return new EqualsBuilder().append(id, rhs.getId()).append(date, rhs.getDate()).append(action, rhs.getAction()).append(actionStatus,
|
80
|
rhs.getActionStatus()).append(parameters, rhs.getParameters()).isEquals();
|
81
|
}
|
82
|
|
83
|
/**
|
84
|
* {@inheritDoc}
|
85
|
*
|
86
|
* @see java.lang.Object#hashCode()
|
87
|
*/
|
88
|
@Override
|
89
|
public int hashCode() {
|
90
|
return new HashCodeBuilder(HASH_SEED, HASH_SEED_2).append(id).append(date).append(action).append(actionStatus).append(parameters).toHashCode();
|
91
|
}
|
92
|
|
93
|
@Override
|
94
|
public String getDate() {
|
95
|
return date;
|
96
|
}
|
97
|
|
98
|
@Override
|
99
|
public void setDate(final String date) {
|
100
|
this.date = date;
|
101
|
}
|
102
|
|
103
|
@Override
|
104
|
public String getId() {
|
105
|
return id;
|
106
|
}
|
107
|
|
108
|
@Override
|
109
|
public void setId(final String id) { // NOPMD
|
110
|
this.id = id;
|
111
|
}
|
112
|
|
113
|
@Override
|
114
|
public String getAction() {
|
115
|
return action;
|
116
|
}
|
117
|
|
118
|
@Override
|
119
|
public void setAction(final String action) {
|
120
|
this.action = action;
|
121
|
}
|
122
|
|
123
|
@Override
|
124
|
public List<BlackboardParameter> getParameters() {
|
125
|
return parameters;
|
126
|
}
|
127
|
|
128
|
public void setParameters(final List<BlackboardParameter> parameters) {
|
129
|
this.parameters = parameters;
|
130
|
}
|
131
|
|
132
|
@Override
|
133
|
public ActionStatus getActionStatus() {
|
134
|
return actionStatus;
|
135
|
}
|
136
|
|
137
|
@Override
|
138
|
public void setActionStatus(final ActionStatus actionStatus) {
|
139
|
this.actionStatus = actionStatus;
|
140
|
}
|
141
|
|
142
|
}
|