Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/common/ResultRow.java @ 9202:b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
author | mschaefer |
---|---|
date | Mon, 02 Jul 2018 07:33:53 +0200 |
parents | e3b3ce32c825 |
children |
rev | line source |
---|---|
8999 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.common; | |
11 | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
8999
diff
changeset
|
12 import java.io.Serializable; |
8999 | 13 import java.util.HashMap; |
14 import java.util.Map; | |
15 | |
16 import org.dive4elements.artifacts.CallContext; | |
17 | |
18 /** | |
19 * Generic container for results that come in rows. | |
20 * | |
21 * @author Gernot Belger | |
22 */ | |
23 public class ResultRow implements Serializable { | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
8999
diff
changeset
|
24 private static final long serialVersionUID = 1L; |
8999 | 25 |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
8999
diff
changeset
|
26 private final Map<IResultType, Object> values = new HashMap<>(); |
8999 | 27 |
28 public static ResultRow create() { | |
29 return new ResultRow(); | |
30 } | |
31 | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
8999
diff
changeset
|
32 public static ResultRow create(final ResultRow src) { |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
8999
diff
changeset
|
33 final ResultRow dst = create(); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
8999
diff
changeset
|
34 dst.values.putAll(src.values); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
8999
diff
changeset
|
35 return dst; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
8999
diff
changeset
|
36 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
8999
diff
changeset
|
37 |
8999 | 38 protected ResultRow() { |
39 } | |
40 | |
41 public ResultRow putValue(final IResultType type, final Object value) { | |
42 | |
43 this.values.put(type, value); | |
44 | |
45 /* chain me */ | |
46 return this; | |
47 } | |
48 | |
49 public String exportValue(final CallContext context, final IResultType type) { | |
50 final Object value = this.values.get(type); | |
51 return type.exportValue(context, value); | |
52 } | |
53 | |
54 public double getDoubleValue(final IResultType type) { | |
55 final Object value = this.values.get(type); | |
56 return type.asDouble(value); | |
57 } | |
58 | |
59 public Object getValue(final IResultType type) { | |
60 return this.values.get(type); | |
61 } | |
62 } |