comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents ef0ec2498dd0
children 0a5239a1e46e
comparison
equal deleted inserted replaced
8855:d7c005e12af0 8856:5e38e2924c07
63 /* GF_BED_LOAD_SUSP_SAND */ Station.BED_LOAD, 63 /* GF_BED_LOAD_SUSP_SAND */ Station.BED_LOAD,
64 /* GF_SUSP_LOAD */ Station.SUSPENDED 64 /* GF_SUSP_LOAD */ Station.SUSPENDED
65 }; 65 };
66 66
67 public static final int measurementStationType(int grainFraction) { 67 public static final int measurementStationType(int grainFraction) {
68 return grainFraction < 0 || grainFraction >= MEASUREMENT_STATION_GF.length 68 return grainFraction < 0
69 || grainFraction >= MEASUREMENT_STATION_GF.length
69 ? Station.UNKNOWN 70 ? Station.UNKNOWN
70 : MEASUREMENT_STATION_GF[grainFraction]; 71 : MEASUREMENT_STATION_GF[grainFraction];
71 } 72 }
72 73
73 public static final int grainFractionIndex(String name) { 74 public static final int grainFractionIndex(String name) {
246 } 247 }
247 } 248 }
248 } 249 }
249 } 250 }
250 251
251 public void allLoadsWithValue(Collection<Load> loads, Integer sqRelationTimeInterval) { 252 public void allLoadsWithValue(
252 253 Collection<Load> loads,
254 Integer sqRelationTimeInterval
255 ) {
253 for (List<Value> values: grainFractions) { 256 for (List<Value> values: grainFractions) {
254 if (values == null) { 257 if (values == null) {
255 continue; 258 continue;
256 } 259 }
257 for (Value value: values) { 260 for (Value value: values) {
259 continue; 262 continue;
260 } 263 }
261 Load load = value.getLoad(); 264 Load load = value.getLoad();
262 Integer sqId = load.getSQRelationTimeIntervalId(); 265 Integer sqId = load.getSQRelationTimeIntervalId();
263 if ((sqRelationTimeInterval == null) 266 if ((sqRelationTimeInterval == null)
264 || sqId != null && sqId.equals(sqRelationTimeInterval)) { 267 || sqId != null
268 && sqId.equals(sqRelationTimeInterval)
269 ) {
265 loads.add(load); 270 loads.add(load);
266 } 271 }
267 } 272 }
268 } 273 }
269 } 274 }
290 295
291 public void merge(Station other) { 296 public void merge(Station other) {
292 this.type |= other.type; 297 this.type |= other.type;
293 for (int i = 0, N = grainFractions.size(); i < N; ++i) { 298 for (int i = 0, N = grainFractions.size(); i < N; ++i) {
294 grainFractions.set(i, 299 grainFractions.set(i,
295 mergeValues(grainFractions.get(i), other.grainFractions.get(i))); 300 mergeValues(
296 } 301 grainFractions.get(i), other.grainFractions.get(i)));
297 } 302 }
298 303 }
299 private static final Comparator<Value> ID_CMP = new Comparator<Value>() { 304
305 private static final Comparator<Value> ID_CMP =
306 new Comparator<Value>() {
300 @Override 307 @Override
301 public int compare(Value a, Value b) { 308 public int compare(Value a, Value b) {
302 return a.getLoad().getId() - b.getLoad().getId(); 309 return a.getLoad().getId() - b.getLoad().getId();
303 } 310 }
304 }; 311 };
352 } 359 }
353 } 360 }
354 } 361 }
355 } 362 }
356 363
357 public List<Value> filterGrainFraction(int grainFraction, Value.Filter filter) { 364 public List<Value> filterGrainFraction(
365 int grainFraction,
366 Value.Filter filter
367 ) {
358 final List<Value> result = new ArrayList<Value>(); 368 final List<Value> result = new ArrayList<Value>();
359 filterGrainFraction(grainFraction, filter, new Value.Visitor() { 369 filterGrainFraction(grainFraction, filter, new Value.Visitor() {
360 @Override 370 @Override
361 public void visit(Value value) { 371 public void visit(Value value) {
362 result.add(value); 372 result.add(value);
490 return 1; 500 return 1;
491 } 501 }
492 } 502 }
493 }; 503 };
494 504
495 public static final Comparator<Load> LOAD_SQ_TI_CMP = new Comparator<Load>() { 505 public static final Comparator<Load> LOAD_SQ_TI_CMP =
506 new Comparator<Load>() {
496 @Override 507 @Override
497 public int compare(Load a, Load b) { 508 public int compare(Load a, Load b) {
498 Integer a_id = a.getSQRelationTimeIntervalId(); 509 Integer a_id = a.getSQRelationTimeIntervalId();
499 Integer b_id = b.getSQRelationTimeIntervalId(); 510 Integer b_id = b.getSQRelationTimeIntervalId();
500 if (a_id == null && b_id == null) { 511 if (a_id == null && b_id == null) {
509 return a_id - b_id; 520 return a_id - b_id;
510 } 521 }
511 }; 522 };
512 523
513 /** Find all loads in the range a/b with the according sq_time_interval */ 524 /** Find all loads in the range a/b with the according sq_time_interval */
514 public Collection<Load> findLoadsWithValue(double a, double b, final Integer sqRelationTimeInterval) { 525 public Collection<Load> findLoadsWithValue(
526 double a,
527 double b,
528 final Integer sqRelationTimeInterval
529 ) {
515 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP); 530 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP);
516 531
517 findStations(a, b, new Visitor() { 532 findStations(a, b, new Visitor() {
518 @Override 533 @Override
519 public void visit(Station station) { 534 public void visit(Station station) {
526 541
527 /** Get a list of loads with unique sq_time_intervals. 542 /** Get a list of loads with unique sq_time_intervals.
528 * 543 *
529 * This is mainly a convenience function for the SedimentLoadInfoService. 544 * This is mainly a convenience function for the SedimentLoadInfoService.
530 */ 545 */
531 public Collection<Load> findDistinctSQTimeIntervalNonEpochLoadsWithValue(double a, double b) { 546 public Collection<Load> findDistinctSQTimeIntervalNonEpochLoadsWithValue(
547 double a,
548 double b
549 ) {
532 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_SQ_TI_CMP); 550 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_SQ_TI_CMP);
533 551
534 findStations(a, b, new Visitor() { 552 findStations(a, b, new Visitor() {
535 @Override 553 @Override
536 public void visit(Station station) { 554 public void visit(Station station) {

http://dive4elements.wald.intevation.org