blob: 71adcbdce83c74ed513c7f1a42b2d27b7ce717ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package cgeo.geocaching.connector.gc;
/**
* Property with certainty. When merging properties, the one with higher certainty wins.
*
* @param <T>
*/
public class UncertainProperty<T> {
private final T value;
private final int certaintyLevel;
public UncertainProperty(T value) {
this(value, Tile.ZOOMLEVEL_MAX + 1);
}
public UncertainProperty(T value, int certaintyLevel) {
this.value = value;
this.certaintyLevel = certaintyLevel;
}
public T getValue() {
return value;
}
public int getCertaintyLevel() {
return certaintyLevel;
}
public UncertainProperty<T> getMergedProperty(final UncertainProperty<T> other) {
if (null == other || null == other.value) {
return this;
}
if (null == this.value) {
return other;
}
if (other.certaintyLevel > certaintyLevel) {
return other;
}
return this;
}
public static <T> UncertainProperty<T> getMergedProperty(UncertainProperty<T> property, UncertainProperty<T> otherProperty) {
if (null == property) {
return otherProperty;
}
return property.getMergedProperty(otherProperty);
}
}
|