Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
497:67fd63e4ef66 | 498:8ab04de0b879 |
---|---|
1 package de.intevation.flys.importer; | |
2 | |
3 import de.intevation.flys.model.WstColumnValue; | |
4 import de.intevation.flys.model.DischargeTableValue; | |
5 | |
6 | |
7 public class IdValueKey { | |
8 | |
9 protected int id; | |
10 protected double a; | |
11 protected double b; | |
12 | |
13 | |
14 public IdValueKey(WstColumnValue value) { | |
15 this.id = value.getWstColumn().getId(); | |
16 this.a = value.getPosition().doubleValue(); | |
17 this.b = value.getW().doubleValue(); | |
18 } | |
19 | |
20 public IdValueKey(DischargeTableValue value) { | |
21 this.id = value.getDischargeTable().getId(); | |
22 this.a = value.getQ().doubleValue(); | |
23 this.b = value.getW().doubleValue(); | |
24 } | |
25 | |
26 | |
27 public IdValueKey(int id, double a, double b) { | |
28 this.id = id; | |
29 this.a = a; | |
30 this.b = b; | |
31 } | |
32 | |
33 private static final int hashDouble(double d) { | |
34 long v = Double.doubleToLongBits(d); | |
35 return (int)(v^(v>>>32)); | |
36 } | |
37 | |
38 public int hashCode() { | |
39 int a = id; | |
40 int b = hashDouble(a); | |
41 int c = hashDouble(b); | |
42 | |
43 return (a | (b << 10) | (c << 20)); | |
44 } | |
45 | |
46 | |
47 public boolean equals(Object obj) { | |
48 if (!(obj instanceof IdValueKey)) { | |
49 return false; | |
50 } | |
51 | |
52 IdValueKey other = (IdValueKey) obj; | |
53 | |
54 return id == other.id | |
55 && a == other.a | |
56 && b == other.b; | |
57 } | |
58 } | |
59 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |