Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTableCacheKey.java @ 4631:d35d316049e8
A little optimization and handle the case that there are duplicates in the values.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 03 Dec 2012 21:16:15 +0100 |
parents | 305a338c43c2 |
children |
rev | line source |
---|---|
626
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.io.Serializable; |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
1928
305a338c43c2
Minor cosmetic (doc).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
632
diff
changeset
|
5 /** |
305a338c43c2
Minor cosmetic (doc).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
632
diff
changeset
|
6 * Cache Key (identifier) for WstValueTables. |
305a338c43c2
Minor cosmetic (doc).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
632
diff
changeset
|
7 */ |
626
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 public final class WstValueTableCacheKey |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 implements Serializable |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 { |
632
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
626
diff
changeset
|
11 public static final String CACHE_NAME = "wst-value-table"; |
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
626
diff
changeset
|
12 |
626
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 private int riverId; |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 private int kind; |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 public WstValueTableCacheKey(int riverId, int kind) { |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 this.riverId = riverId; |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 this.kind = kind; |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 } |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 public int hashCode() { |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 return (riverId << 8) | kind; |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 } |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 public boolean equals(Object other) { |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 if (!(other instanceof WstValueTableCacheKey)) { |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 return false; |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 } |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 WstValueTableCacheKey o = (WstValueTableCacheKey)other; |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 return riverId == o.riverId && kind == o.kind; |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 } |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 } |
e3ee131d5dd3
Moved WST value table cache key to a separate class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |