aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/utils/UncertainProperty.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/utils/UncertainProperty.java')
-rw-r--r--main/src/cgeo/geocaching/utils/UncertainProperty.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/utils/UncertainProperty.java b/main/src/cgeo/geocaching/utils/UncertainProperty.java
new file mode 100644
index 0000000..2187558
--- /dev/null
+++ b/main/src/cgeo/geocaching/utils/UncertainProperty.java
@@ -0,0 +1,39 @@
+package cgeo.geocaching.utils;
+
+import cgeo.geocaching.connector.gc.Tile;
+
+public class UncertainProperty<T> {
+
+ private final T value;
+ private final int certaintyLevel;
+
+ public UncertainProperty(T value) {
+ this.value = value;
+ this.certaintyLevel = 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 (other == null) {
+ return this;
+ }
+ if (other.certaintyLevel > certaintyLevel) {
+ return other;
+ }
+
+ return this;
+ }
+
+}