Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/importer/IdValueKey.java @ 498:8ab04de0b879
Importer: Cache the discharge table values, too.
flys-backend/trunk@1852 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 08 May 2011 17:55:49 +0000 |
parents | |
children | d50cd3a632e0 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/IdValueKey.java Sun May 08 17:55:49 2011 +0000 @@ -0,0 +1,59 @@ +package de.intevation.flys.importer; + +import de.intevation.flys.model.WstColumnValue; +import de.intevation.flys.model.DischargeTableValue; + + +public class IdValueKey { + + protected int id; + protected double a; + protected double b; + + + public IdValueKey(WstColumnValue value) { + this.id = value.getWstColumn().getId(); + this.a = value.getPosition().doubleValue(); + this.b = value.getW().doubleValue(); + } + + public IdValueKey(DischargeTableValue value) { + this.id = value.getDischargeTable().getId(); + this.a = value.getQ().doubleValue(); + this.b = value.getW().doubleValue(); + } + + + public IdValueKey(int id, double a, double b) { + this.id = id; + this.a = a; + this.b = b; + } + + private static final int hashDouble(double d) { + long v = Double.doubleToLongBits(d); + return (int)(v^(v>>>32)); + } + + public int hashCode() { + int a = id; + int b = hashDouble(a); + int c = hashDouble(b); + + return (a | (b << 10) | (c << 20)); + } + + + public boolean equals(Object obj) { + if (!(obj instanceof IdValueKey)) { + return false; + } + + IdValueKey other = (IdValueKey) obj; + + return id == other.id + && a == other.a + && b == other.b; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :