comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/model/FixingsOverviewInfo.java @ 9099:850ce16034e9

2.3.4.1.10 Berechnung mit Start-km > End-km
author gernotbelger
date Mon, 28 May 2018 13:22:45 +0200
parents 0f3dad5d74a2
children 2a1dcee5e54a
comparison
equal deleted inserted replaced
9098:32dd7e761e4e 9099:850ce16034e9
7 */ 7 */
8 8
9 package org.dive4elements.river.client.shared.model; 9 package org.dive4elements.river.client.shared.model;
10 10
11 import java.io.Serializable; 11 import java.io.Serializable;
12 12 import java.util.ArrayList;
13 import java.util.List; 13 import java.util.List;
14 import java.util.ArrayList;
15 14
16 public class FixingsOverviewInfo implements Serializable { 15 public class FixingsOverviewInfo implements Serializable {
17 16
18 protected List<FixEvent> events; 17 protected List<FixEvent> events;
19 protected String river; 18 protected String river;
20 protected double from; 19 protected double from;
21 protected double to; 20 protected double to;
22 protected int rid; 21 protected int rid;
23 protected String html; 22 protected String html;
24 23
25 protected FixingsOverviewInfo() {} 24 private FixingsOverviewInfo() {
25 }
26 26
27 public FixingsOverviewInfo( 27 public FixingsOverviewInfo(final int rid, final String river, final double from, final double to, final List<FixEvent> events, final String html) {
28 int rid,
29 String river,
30 double from,
31 double to,
32 List<FixEvent> events,
33 String html
34 ) {
35 this.rid = rid; 28 this.rid = rid;
36 this.river = river; 29 this.river = river;
37 this.from = from; 30 this.from = from;
38 this.to = to; 31 this.to = to;
39 this.events = new ArrayList<FixEvent>(events); 32 this.events = new ArrayList<FixEvent>(events);
46 39
47 public String getRiver() { 40 public String getRiver() {
48 return this.river; 41 return this.river;
49 } 42 }
50 43
51 public double getFrom() { 44 public double getLowerKm() {
52 return this.from; 45 return Math.min(this.from, this.to);
53 } 46 }
54 47
55 public double getTo() { 48 public double getUpperKm() {
56 return this.to; 49 return Math.max(this.from, this.to);
57 } 50 }
51
52 // public double getFrom() {
53 // return this.from < this.to ? this.from : this.to; // TODO: prüfung wieder rausnehmen, hat glaube ich keinen
54 // sinnvollen effekt.
55 // }
56 //
57 // public double getTo() {
58 // return this.to > this.from ? this.to : this.from;
59 // }
58 60
59 public List<FixEvent> getEvents() { 61 public List<FixEvent> getEvents() {
60 return this.events; 62 return this.events;
61 } 63 }
62 64
63 public FixEvent getEventByCId(String cid) { 65 public FixEvent getEventByCId(final String cid) {
64 for (FixEvent event: events) { 66 for (final FixEvent event : this.events) {
65 if (event.getCId().equals(cid)) { 67 if (event.getCId().equals(cid)) {
66 return event; 68 return event;
67 } 69 }
68 } 70 }
69 return null; 71 return null;
71 73
72 public String getHTML() { 74 public String getHTML() {
73 return this.html; 75 return this.html;
74 } 76 }
75 77
76
77 public static class FixEvent implements Serializable { 78 public static class FixEvent implements Serializable {
78 protected String cid; 79 protected String cid;
79 protected String date; 80 protected String date;
80 protected String description; 81 protected String description;
81 protected List<Sector> sectors; 82 protected List<Sector> sectors;
82 83
83 protected FixEvent () {} 84 protected FixEvent() {
85 }
84 86
85 public FixEvent( 87 public FixEvent(final String cid, final String date, final String description, final List<Sector> sectors) {
86 String cid,
87 String date,
88 String description,
89 List<Sector> sectors
90 ) {
91 this.cid = cid; 88 this.cid = cid;
92 this.date = date; 89 this.date = date;
93 this.description = description; 90 this.description = description;
94 this.sectors = new ArrayList<Sector>(sectors); 91 this.sectors = new ArrayList<Sector>(sectors);
95 } 92 }
114 public static class Sector implements Serializable { 111 public static class Sector implements Serializable {
115 protected int cls; 112 protected int cls;
116 protected double from; 113 protected double from;
117 protected double to; 114 protected double to;
118 115
119 protected Sector () {} 116 protected Sector() {
117 }
120 118
121 public Sector( 119 public Sector(final int cls, final double from, final double to) {
122 int cls,
123 double from,
124 double to
125 ) {
126 this.cls = cls; 120 this.cls = cls;
127 this.from = from; 121 this.from = from;
128 this.to = to; 122 this.to = to;
129 } 123 }
130 124

http://dive4elements.wald.intevation.org