View Javadoc
1   package fr.ifremer.tutti.persistence.entities.protocol;
2   
3   /*
4    * #%L
5    * Tutti :: Persistence
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  
29  import java.util.Objects;
30  
31  public class CalcifiedPiecesSamplingDefinitionBean extends AbstractCalcifiedPiecesSamplingDefinitionBean {
32  
33      @Override
34      public boolean equals(Object o) {
35          if (this == o) return true;
36          if (o == null || getClass() != o.getClass()) return false;
37          CalcifiedPiecesSamplingDefinitionBean that = (CalcifiedPiecesSamplingDefinitionBean) o;
38          return minSize == that.minSize &&
39                  Objects.equals(maxSize, that.maxSize) &&
40                  Objects.equals(maturity, that.maturity);
41      }
42  
43      @Override
44      public int hashCode() {
45          return Objects.hash(minSize, maxSize, maturity);
46      }
47  
48      @Override
49      public String toString() {
50          MoreObjects.ToStringHelper toStringHelper =
51                  MoreObjects.toStringHelper(CalcifiedPiecesSamplingDefinition.class)
52                             .add(PROPERTY_MIN_SIZE, minSize)
53                             .add(PROPERTY_MAX_SIZE, maxSize == null ? "∞" : maxSize)
54                             .add(PROPERTY_SEX, sex)
55                             .add(PROPERTY_SAMPLING_INTERVAL, samplingInterval);
56  
57          if (maturity != null) {
58              toStringHelper.add(PROPERTY_MATURITY, maturity);
59          }
60          if (maxByLenghtStep != null && maxByLenghtStep > 0) {
61              toStringHelper.add(PROPERTY_MAX_BY_LENGHT_STEP, maxByLenghtStep);
62          }
63          if (operationLimitation != null && operationLimitation > 0) {
64              toStringHelper.add(PROPERTY_OPERATION_LIMITATION, operationLimitation);
65          }
66          if (zoneLimitation != null && zoneLimitation > 0) {
67              toStringHelper.add(PROPERTY_ZONE_LIMITATION, zoneLimitation);
68          }
69  
70          return toStringHelper.toString();
71      }
72  }