1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.opencastproject.job.api;
23
24 import static org.opencastproject.util.EqualsUtil.eq;
25 import static org.opencastproject.util.EqualsUtil.hash;
26
27 import org.opencastproject.util.data.Tuple;
28
29 import java.util.Collections;
30 import java.util.Date;
31 import java.util.List;
32 import java.util.Map;
33
34 public final class IncidentImpl implements Incident {
35 private final long id;
36 private final long jobId;
37 private final String serviceType;
38 private final String processingHost;
39 private final Date timestamp;
40 private final Severity severity;
41 private final String code;
42 private final List<Tuple<String, String>> details;
43 private final Map<String, String> parameters;
44
45 public IncidentImpl(long id,
46 long jobId,
47 String serviceType,
48 String processingHost,
49 Date timestamp,
50 Severity severity,
51 String code,
52 List<Tuple<String, String>> details,
53 Map<String, String> parameters) {
54 this.id = id;
55 this.jobId = jobId;
56 this.serviceType = serviceType;
57 this.processingHost = processingHost;
58 this.timestamp = new Date(timestamp.getTime());
59 this.severity = severity;
60 this.code = code;
61 this.details = Collections.unmodifiableList(details);
62 this.parameters = Collections.unmodifiableMap(parameters);
63 }
64
65 @Override
66 public long getId() {
67 return id;
68 }
69
70 @Override
71 public long getJobId() {
72 return jobId;
73 }
74
75 @Override
76 public String getServiceType() {
77 return serviceType;
78 }
79
80 @Override
81 public String getProcessingHost() {
82 return processingHost;
83 }
84
85 @Override
86 public Date getTimestamp() {
87 return timestamp;
88 }
89
90 @Override
91 public Severity getSeverity() {
92 return severity;
93 }
94
95 @Override
96 public String getCode() {
97 return code;
98 }
99
100 @Override
101 public List<Tuple<String, String>> getDetails() {
102 return details;
103 }
104
105 @Override
106 public Map<String, String> getDescriptionParameters() {
107 return parameters;
108 }
109
110 @Override
111 public int hashCode() {
112 return hash(id, jobId, serviceType, processingHost, timestamp, severity, code, details, parameters);
113 }
114
115 @Override
116 public boolean equals(Object that) {
117 return (this == that) || (that instanceof Incident && eqFields((Incident) that));
118 }
119
120 private boolean eqFields(Incident that) {
121 return eq(id, that.getId())
122 && eq(jobId, that.getJobId())
123 && eq(serviceType, that.getServiceType())
124 && eq(processingHost, that.getProcessingHost())
125 && eq(timestamp, that.getTimestamp())
126 && eq(severity, that.getSeverity())
127 && eq(code, that.getCode())
128 && eq(details, that.getDetails())
129 && eq(parameters, that.getDescriptionParameters());
130 }
131 }