View Javadoc
1   package fr.ifremer.tutti.ichtyometer.interactive;
2   
3   /*
4    * #%L
5    * Tutti :: Ichtyometer API
6    * %%
7    * Copyright (C) 2012 - 2014 Ifremer
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as
11   * published by the Free Software Foundation, either version 3 of the 
12   * License, or (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Public 
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/gpl-3.0.html>.
22   * #L%
23   */
24  
25  import org.apache.commons.lang3.builder.ToStringBuilder;
26  
27  import java.io.Serializable;
28  
29  /**
30   * Created on 1/28/14.
31   *
32   * @author Tony Chemit - chemit@codelutin.com
33   * @since 3.1
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  }