Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultRow.java @ 8948:a4f1ac81f26d
Work on SINFO-FlowDepthMinMax.
Also rework of result row stuff, in order to reduce abstraction, using result type concept
author | gernotbelger |
---|---|
date | Wed, 14 Mar 2018 14:10:32 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultRow.java Wed Mar 14 14:10:32 2018 +0100 @@ -0,0 +1,56 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ +package org.dive4elements.river.artifacts.sinfo.common; + +import java.io.Serializable; +import java.util.EnumMap; +import java.util.Map; + +import org.dive4elements.artifacts.CallContext; + +/** + * Generic container for results that come in rows. + * + * @author Gernot Belger + */ +public final class SInfoResultRow implements Serializable { + private static final long serialVersionUID = 1L; + + private final Map<SInfoResultType, Object> values = new EnumMap<>(SInfoResultType.class); + + public static SInfoResultRow create() { + return new SInfoResultRow(); + } + + private SInfoResultRow() { + } + + public SInfoResultRow putValue(final SInfoResultType type, final Object value) { + + this.values.put(type, value); + + /* chain me */ + return this; + } + + public String exportValue(final CallContext context, final SInfoResultType type) { + final Object value = this.values.get(type); + return type.exportValue(context, value); + } + + public double getDoubleValue(final SInfoResultType type) { + final Object value = this.values.get(type); + return type.asDouble(value); + } + + public Object getValue(final SInfoResultType type) { + return this.values.get(type); + } +} \ No newline at end of file