1 package fr.ifremer.tutti.ichtyometer.interactive;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import org.apache.commons.lang3.builder.ToStringBuilder;
26
27 import java.io.Serializable;
28
29
30
31
32
33
34
35 public class Command implements Serializable {
36
37 private static final long serialVersionUID = 1L;
38
39 protected final String question;
40
41 protected final String response;
42
43 protected final String crc;
44
45 public Command(String question, String response, String crc) {
46 this.question = question;
47 this.response = response;
48 this.crc = crc;
49 }
50
51 public String getQuestion() {
52 return question;
53 }
54
55 public String getResponse() {
56 return response;
57 }
58
59 public String getCrc() {
60 return crc;
61 }
62
63 @Override
64 public String toString() {
65 return new ToStringBuilder(this)
66 .append("question", question)
67 .append("response", response)
68 .append("crc", crc)
69 .toString();
70 }
71
72 @Override
73 public boolean equals(Object o) {
74 if (this == o) return true;
75 if (!(o instanceof Command)) return false;
76
77 Command command = (Command) o;
78
79 return question.equals(command.question) && response.equals(command.response) &&
80 !(crc != null ? !crc.equals(command.crc) : command.crc != null);
81
82 }
83
84 @Override
85 public int hashCode() {
86 int result = question.hashCode();
87 result = 31 * result + response.hashCode();
88 result = 31 * result + (crc != null ? crc.hashCode() : 0);
89 return result;
90 }
91 }