View Javadoc
1   package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency;
2   
3   /*
4    * #%L
5    * Tutti :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2012 - 2016 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU General Public License as
13   * published by the Free Software Foundation, either version 3 of the
14   * License, or (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU General Public
22   * License along with this program.  If not, see
23   * <http://www.gnu.org/licenses/gpl-3.0.html>.
24   * #L%
25   */
26  
27  import com.google.common.base.MoreObjects;
28  import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
29  
30  import java.util.Objects;
31  
32  /**
33   * Contient l'état d'une observation individuelle utilisée par les modes de recopie pour savoir ce qu'il faut
34   * déporter dans les mensurations.
35   *
36   * Created on 15/04/16.
37   *
38   * @author Tony Chemit - chemit@codelutin.com
39   */
40  public class IndividualObservationBatchRowState {
41  
42      private final Float size;
43      private final Float weight;
44      private final CaracteristicQualitativeValue maturity;
45      private final CaracteristicQualitativeValue gender;
46      private final String samplingCode;
47      private final boolean valid;
48  
49      public IndividualObservationBatchRowState(Float size,
50                                                Float weight,
51                                                CaracteristicQualitativeValue maturity,
52                                                CaracteristicQualitativeValue gender,
53                                                String samplingCode,
54                                                boolean valid) {
55          this.size = size;
56          this.weight = weight;
57          this.maturity = maturity;
58          this.gender = gender;
59          this.samplingCode = samplingCode;
60          this.valid = valid;
61      }
62  
63      public boolean isValid() {
64          return valid;
65      }
66  
67      public Float getSize() {
68          return size;
69      }
70  
71      public Float getWeight() {
72          return weight;
73      }
74  
75      public CaracteristicQualitativeValue getMaturity() {
76          return maturity;
77      }
78  
79      public CaracteristicQualitativeValue getGender() {
80          return gender;
81      }
82  
83      public String getSamplingCode() {
84          return samplingCode;
85      }
86  
87      public boolean withSamplingCode() {
88          return samplingCode != null;
89      }
90  
91      @Override
92      public boolean equals(Object o) {
93          if (this == o) return true;
94          if (o == null || getClass() != o.getClass()) return false;
95          IndividualObservationBatchRowState that = (IndividualObservationBatchRowState) o;
96          return Objects.equals(size, that.size) &&
97                  Objects.equals(weight, that.weight) &&
98                  Objects.equals(maturity, that.maturity) &&
99                  Objects.equals(gender, that.gender) &&
100                 Objects.equals(samplingCode, that.samplingCode);
101     }
102 
103     @Override
104     public int hashCode() {
105         return Objects.hash(size, weight);
106     }
107 
108     @Override
109     public String toString() {
110         return MoreObjects.toStringHelper(this)
111                           .add("size", size)
112                           .add("weight", weight)
113                           .add("maturity", maturity)
114                           .add("gender", gender)
115                           .add("samplingCode", samplingCode)
116                           .add("valid", valid)
117                           .toString();
118     }
119 }