blob: 204fc89949f40bf6607b0d605ec593f41b5eff4d (
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
|
package cgeo.geocaching.connector.gc;
/**
* Property with certainty. When merging properties, the one with higher certainty wins.
*
*/
public class UncertainProperty<T> {
private final T value;
private final int certaintyLevel;
public UncertainProperty(final T value) {
this(value, Tile.ZOOMLEVEL_MAX + 1);
}
public UncertainProperty(final T value, final 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(final UncertainProperty<T> property, final UncertainProperty<T> otherProperty) {
if (null == property) {
return otherProperty;
}
return property.getMergedProperty(otherProperty);
}
}
|