1 package au.gov.amsa.ihs.model; 2 3 import org.joda.time.DateTime; 4 5 import com.google.common.base.Optional; 6 import com.google.common.base.Preconditions; 7 8 public class Ship { 9 10 private final String imo; 11 private final Optional<String> mmsi; 12 private final Optional<String> type2; 13 private final Optional<String> type3; 14 private final Optional<String> type4; 15 private final Optional<String> type5; 16 private final Optional<Long> grossTonnage; 17 private final Optional<String> classificationSocietyCode; 18 private final Optional<String> flagCode; 19 private final Optional<String> groupBeneficialOwnerCompanyCode; 20 private final Optional<String> groupBeneficialOwnerCountryOfDomicileCode; 21 private final Optional<String> countryOfBuildCode; 22 private final Optional<Integer> yearOfBuild; 23 private final Optional<Integer> monthOfBuild; 24 private final Optional<Float> deadweightTonnage; 25 private final Optional<String> statCode5; 26 private final Optional<Float> lengthOverallMetres; 27 private final Optional<Float> breadthMetres; 28 private final Optional<Float> displacementTonnage; 29 private final Optional<Float> draughtMetres; 30 private final Optional<Float> speedKnots; 31 private final Optional<DateTime> lastUpdateTime; 32 private final Optional<String> name; 33 private final Optional<String> shipBuilderCompanyCode; 34 35 private Ship(String imo, Optional<String> mmsi, Optional<String> type2, Optional<String> type3, 36 Optional<String> type4, Optional<String> type5, Optional<Long> grossTonnage, 37 Optional<String> classificationSocietyCode, Optional<String> flagCode, 38 Optional<String> groupBeneficialOwnerCompanyCode, 39 Optional<String> groupBeneficialOwnerCountryOfDomicileCode, 40 Optional<String> countryOfBuildCode, Optional<Integer> yearOfBuild, 41 Optional<Integer> monthOfBuild, Optional<Float> deadweightTonnage, 42 Optional<String> statCode5, Optional<Float> lengthOverallMetres, 43 Optional<Float> breadthMetres, Optional<Float> displacementTonnage, 44 Optional<Float> draughtMetres, Optional<Float> speedKnots, 45 Optional<DateTime> lastUpdateTime, Optional<String> name, 46 Optional<String> shipBuilderCompanyCode) { 47 Preconditions.checkNotNull(imo); 48 Preconditions.checkNotNull(mmsi); 49 Preconditions.checkNotNull(type2); 50 Preconditions.checkNotNull(type3); 51 Preconditions.checkNotNull(type4); 52 Preconditions.checkNotNull(type5); 53 Preconditions.checkNotNull(grossTonnage); 54 Preconditions.checkNotNull(classificationSocietyCode); 55 Preconditions.checkNotNull(flagCode); 56 Preconditions.checkNotNull(groupBeneficialOwnerCompanyCode); 57 Preconditions.checkNotNull(groupBeneficialOwnerCountryOfDomicileCode); 58 Preconditions.checkNotNull(countryOfBuildCode); 59 Preconditions.checkNotNull(yearOfBuild); 60 Preconditions.checkNotNull(monthOfBuild); 61 Preconditions.checkNotNull(deadweightTonnage); 62 Preconditions.checkNotNull(statCode5); 63 Preconditions.checkNotNull(lengthOverallMetres); 64 Preconditions.checkNotNull(breadthMetres); 65 Preconditions.checkNotNull(displacementTonnage); 66 Preconditions.checkNotNull(draughtMetres); 67 Preconditions.checkNotNull(speedKnots); 68 Preconditions.checkNotNull(lastUpdateTime); 69 Preconditions.checkNotNull(name); 70 Preconditions.checkNotNull(shipBuilderCompanyCode); 71 this.imo = imo; 72 this.mmsi = mmsi; 73 this.type2 = type2; 74 this.type3 = type3; 75 this.type4 = type4; 76 this.type5 = type5; 77 this.grossTonnage = grossTonnage; 78 this.classificationSocietyCode = classificationSocietyCode; 79 this.flagCode = flagCode; 80 this.groupBeneficialOwnerCompanyCode = groupBeneficialOwnerCompanyCode; 81 this.groupBeneficialOwnerCountryOfDomicileCode = groupBeneficialOwnerCountryOfDomicileCode; 82 this.countryOfBuildCode = countryOfBuildCode; 83 this.yearOfBuild = yearOfBuild; 84 this.monthOfBuild = monthOfBuild; 85 this.deadweightTonnage = deadweightTonnage; 86 this.statCode5 = statCode5; 87 this.lengthOverallMetres = lengthOverallMetres; 88 this.breadthMetres = breadthMetres; 89 if (displacementTonnage.isPresent() && displacementTonnage.get() == 0) 90 this.displacementTonnage = Optional.absent(); 91 else 92 this.displacementTonnage = displacementTonnage; 93 this.draughtMetres = draughtMetres; 94 this.speedKnots = speedKnots; 95 this.lastUpdateTime = lastUpdateTime; 96 this.name = name; 97 this.shipBuilderCompanyCode = shipBuilderCompanyCode; 98 } 99 100 public Optional<String> getName() { 101 return name; 102 } 103 104 public String getImo() { 105 return imo; 106 } 107 108 public Optional<String> getMmsi() { 109 return mmsi; 110 } 111 112 public Optional<String> getType2() { 113 return type2; 114 } 115 116 public Optional<String> getType3() { 117 return type3; 118 } 119 120 public Optional<String> getType4() { 121 return type4; 122 } 123 124 public Optional<String> getType5() { 125 return type5; 126 } 127 128 public Optional<Long> getGrossTonnage() { 129 return grossTonnage; 130 } 131 132 public Optional<String> getClassificationSocietyCode() { 133 return classificationSocietyCode; 134 } 135 136 public Optional<String> getFlagCode() { 137 return flagCode; 138 } 139 140 public Optional<String> getGroupBeneficialOwnerCompanyCode() { 141 return groupBeneficialOwnerCompanyCode; 142 } 143 144 public Optional<String> getGroupBeneficialOwnerCountryOfDomicileCode() { 145 return groupBeneficialOwnerCountryOfDomicileCode; 146 } 147 148 public Optional<String> getCountryOfBuildCode() { 149 return countryOfBuildCode; 150 } 151 152 public Optional<Integer> getYearOfBuild() { 153 return yearOfBuild; 154 } 155 156 public Optional<Integer> getMonthOfBuild() { 157 return monthOfBuild; 158 } 159 160 public Optional<Float> getDeadweightTonnage() { 161 return deadweightTonnage; 162 } 163 164 public Optional<String> getStatCode5() { 165 return statCode5; 166 } 167 168 public Optional<Float> getLengthOverallMetres() { 169 return lengthOverallMetres; 170 } 171 172 public Optional<Float> getBreadthMetres() { 173 return breadthMetres; 174 } 175 176 public Optional<Float> getDisplacementTonnage() { 177 return displacementTonnage; 178 } 179 180 public Optional<Float> getDraughtMetres() { 181 return draughtMetres; 182 } 183 184 public Optional<Float> getSpeedKnots() { 185 return speedKnots; 186 } 187 188 public Optional<DateTime> getLastUpdateTime() { 189 return lastUpdateTime; 190 } 191 192 public Optional<String> getShipBuilderCompanyCode() { 193 return shipBuilderCompanyCode; 194 } 195 196 public static Builder builder() { 197 return new Builder(); 198 } 199 200 public static class Builder { 201 202 private String imo; 203 private Optional<String> mmsi; 204 private Optional<String> type2; 205 private Optional<String> type3; 206 private Optional<String> type4; 207 private Optional<String> type5; 208 private Optional<Long> grossTonnage; 209 private Optional<String> classificationSocietyCode; 210 private Optional<String> flagCode; 211 private Optional<String> groupBeneficialOwnerCompanyCode; 212 private Optional<String> groupBeneficialOwnerCountryOfDomicileCode; 213 private Optional<String> countryOfBuildCode; 214 private Optional<Integer> yearOfBuild; 215 private Optional<Integer> monthOfBuild; 216 private Optional<Float> deadweightTonnage; 217 private Optional<String> statCode5; 218 private Optional<Float> lengthOverallMetres; 219 private Optional<Float> breadthMetres; 220 private Optional<Float> displacementTonnage; 221 private Optional<Float> draughtMetres; 222 private Optional<Float> speedKnots; 223 private Optional<DateTime> lastUpdateTime; 224 private Optional<String> name; 225 private Optional<String> shipBuilderCompanyCode; 226 227 private Builder() { 228 } 229 230 public Builder imo(String imo) { 231 this.imo = imo; 232 return this; 233 } 234 235 public Builder mmsi(Optional<String> mmsi) { 236 this.mmsi = mmsi; 237 return this; 238 } 239 240 public Builder type2(Optional<String> type2) { 241 this.type2 = type2; 242 return this; 243 } 244 245 public Builder type3(Optional<String> type3) { 246 this.type3 = type3; 247 return this; 248 } 249 250 public Builder type4(Optional<String> type4) { 251 this.type4 = type4; 252 return this; 253 } 254 255 public Builder type5(Optional<String> type5) { 256 this.type5 = type5; 257 return this; 258 } 259 260 public Builder grossTonnage(Optional<Long> grossTonnage) { 261 this.grossTonnage = grossTonnage; 262 return this; 263 } 264 265 public Builder classificationSocietyCode(Optional<String> classificationSocietyCode) { 266 this.classificationSocietyCode = classificationSocietyCode; 267 return this; 268 } 269 270 public Builder flagCode(Optional<String> flagCode) { 271 this.flagCode = flagCode; 272 return this; 273 } 274 275 public Builder groupBeneficialOwnerCompanyCode( 276 Optional<String> groupBeneficialOwnerCompanyCode) { 277 this.groupBeneficialOwnerCompanyCode = groupBeneficialOwnerCompanyCode; 278 return this; 279 } 280 281 public Builder groupBeneficialOwnerCountryOfDomicileCode( 282 Optional<String> groupBeneficialOwnerCountryOfDomicileCode) { 283 this.groupBeneficialOwnerCountryOfDomicileCode = groupBeneficialOwnerCountryOfDomicileCode; 284 return this; 285 } 286 287 public Builder countryOfBuildCode(Optional<String> countryOfBuildCode) { 288 this.countryOfBuildCode = countryOfBuildCode; 289 return this; 290 } 291 292 public Builder yearOfBuild(Optional<Integer> yearOfBuild) { 293 this.yearOfBuild = yearOfBuild; 294 return this; 295 } 296 297 public Builder monthOfBuild(Optional<Integer> monthOfBuild) { 298 this.monthOfBuild = monthOfBuild; 299 return this; 300 } 301 302 public Builder deadweightTonnage(Optional<Float> dwt) { 303 this.deadweightTonnage = dwt; 304 return this; 305 } 306 307 public Builder statCode5(Optional<String> value) { 308 this.statCode5 = value; 309 return this; 310 } 311 312 public Builder lengthOverallMetres(Optional<Float> value) { 313 this.lengthOverallMetres = value; 314 return this; 315 } 316 317 public Builder breadthMetres(Optional<Float> value) { 318 this.breadthMetres = value; 319 return this; 320 } 321 322 public Builder displacementTonnage(Optional<Float> value) { 323 this.displacementTonnage = value; 324 return this; 325 } 326 327 public Builder draughtMetres(Optional<Float> value) { 328 this.draughtMetres = value; 329 return this; 330 } 331 332 public Builder speedKnots(Optional<Float> value) { 333 this.speedKnots = value; 334 return this; 335 } 336 337 public Builder lastUpdateTime(Optional<DateTime> value) { 338 this.lastUpdateTime = value; 339 return this; 340 } 341 342 public Builder name(Optional<String> name) { 343 this.name = name; 344 return this; 345 } 346 347 public Builder shipBuilderCompanyCode(Optional<String> shipBuilderCompanyCode) { 348 this.shipBuilderCompanyCode = shipBuilderCompanyCode; 349 return this; 350 } 351 352 public Ship build() { 353 return new Ship(imo, mmsi, type2, type3, type4, type5, grossTonnage, 354 classificationSocietyCode, flagCode, groupBeneficialOwnerCompanyCode, 355 groupBeneficialOwnerCountryOfDomicileCode, countryOfBuildCode, yearOfBuild, 356 monthOfBuild, deadweightTonnage, statCode5, lengthOverallMetres, breadthMetres, 357 displacementTonnage, draughtMetres, speedKnots, lastUpdateTime, name, 358 shipBuilderCompanyCode); 359 } 360 } 361 362 @Override 363 public String toString() { 364 StringBuilder b = new StringBuilder(); 365 b.append("Ship [imo="); 366 b.append(imo); 367 b.append(", mmsi="); 368 b.append(mmsi); 369 b.append(", type2="); 370 b.append(type2); 371 b.append(", type3="); 372 b.append(type3); 373 b.append(", type4="); 374 b.append(type4); 375 b.append(", type5="); 376 b.append(type5); 377 b.append(", grossTonnage="); 378 b.append(grossTonnage); 379 b.append(", classificationSocietyCode="); 380 b.append(classificationSocietyCode); 381 b.append(", flagCode="); 382 b.append(flagCode); 383 b.append(", groupBeneficialOwnerCompanyCode="); 384 b.append(groupBeneficialOwnerCompanyCode); 385 b.append(", groupBeneficialOwnerCountryOfDomicileCode="); 386 b.append(groupBeneficialOwnerCountryOfDomicileCode); 387 b.append(", countryOfBuildCode="); 388 b.append(countryOfBuildCode); 389 b.append(", yearOfBuild="); 390 b.append(yearOfBuild); 391 b.append(", monthOfBuild="); 392 b.append(monthOfBuild); 393 b.append(", deadweightTonnage="); 394 b.append(deadweightTonnage); 395 b.append(", statCode5="); 396 b.append(statCode5); 397 b.append(", lengthOverallMetres="); 398 b.append(lengthOverallMetres); 399 b.append(", breadthMetres="); 400 b.append(breadthMetres); 401 b.append(", displacementTonnage="); 402 b.append(displacementTonnage); 403 b.append(", draughtMetres="); 404 b.append(draughtMetres); 405 b.append(", speedKnots="); 406 b.append(speedKnots); 407 b.append(", lastUpdateTime="); 408 b.append(lastUpdateTime); 409 b.append(", name="); 410 b.append(name); 411 b.append(", shipBuilderCompanyCode="); 412 b.append(shipBuilderCompanyCode); 413 b.append("]"); 414 return b.toString(); 415 } 416 417 }