1 package fr.ifremer.tutti.service.sampling;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 import com.google.common.base.MoreObjects;
28 import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
29 import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
30 import fr.ifremer.tutti.persistence.entities.referential.Species;
31
32 import java.util.Objects;
33
34
35
36
37
38
39
40
41
42 public class IndividualObservationSamplingCacheRequest {
43
44 private final FishingOperation fishingOperation;
45 private final Species species;
46 private final Integer lengthClass;
47 private Boolean forcedMaturity;
48 private CaracteristicQualitativeValue maturity;
49 private CaracteristicQualitativeValue gender;
50 private final String samplingCode;
51
52 public IndividualObservationSamplingCacheRequest(FishingOperation fishingOperation,
53 Species species,
54 Integer lengthClass,
55 CaracteristicQualitativeValue maturity,
56 CaracteristicQualitativeValue gender,
57 String samplingCode) {
58 this.fishingOperation = fishingOperation;
59 Objects.requireNonNull(species);
60 this.species = species;
61 this.lengthClass = lengthClass;
62 this.maturity = maturity;
63 this.gender = gender;
64 this.samplingCode = samplingCode;
65 this.forcedMaturity = null;
66 }
67
68 public FishingOperation getFishingOperation() {
69 return fishingOperation;
70 }
71
72 public Species getSpecies() {
73 return species;
74 }
75
76
77
78
79
80
81 public void setGender(CaracteristicQualitativeValue gender) {
82 this.gender = gender;
83 }
84
85 public Boolean getForcedMaturity() {
86 return forcedMaturity;
87 }
88
89
90
91
92
93
94 public void setForcedMaturity(Boolean forcedMaturity) {
95 this.forcedMaturity = forcedMaturity;
96 this.maturity = null;
97 }
98
99 public Integer getLengthClass() {
100 return lengthClass;
101 }
102
103 public CaracteristicQualitativeValue getMaturity() {
104 return maturity;
105 }
106
107 public CaracteristicQualitativeValue getGender() {
108 return gender;
109 }
110
111 public String getSamplingCode() {
112 return samplingCode;
113 }
114
115 public boolean withMaturity() {
116 return maturity != null;
117 }
118
119 public boolean withGender() {
120 return gender != null;
121 }
122
123 public boolean withLengthClass() {
124 return lengthClass != null;
125 }
126
127 public boolean withSamplingCode() {
128 return samplingCode != null;
129 }
130
131 @Override
132 public String toString() {
133
134 MoreObjects.ToStringHelper toStringHelper = MoreObjects.toStringHelper(this)
135 .add("fishingOperation", fishingOperation)
136 .add("species", species);
137 if (withLengthClass()) {
138 toStringHelper.add("lengthClass", lengthClass);
139 }
140 if (withMaturity()) {
141 toStringHelper.add("maturity", maturity);
142 }
143 if (withGender()) {
144 toStringHelper.add("gender", gender);
145 }
146 if (withSamplingCode()) {
147 toStringHelper.add("samplingCode", samplingCode);
148 }
149
150 return toStringHelper.toString();
151
152 }
153 }