diff options
Diffstat (limited to 'main/src/cgeo/geocaching/connector/gc')
| -rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCMap.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/connector/gc/UncertainProperty.java | 52 |
2 files changed, 53 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCMap.java b/main/src/cgeo/geocaching/connector/gc/GCMap.java index 1ab642e..27ce06e 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCMap.java +++ b/main/src/cgeo/geocaching/connector/gc/GCMap.java @@ -15,7 +15,7 @@ import cgeo.geocaching.geopoint.Units; import cgeo.geocaching.geopoint.Viewport; import cgeo.geocaching.network.Parameters; import cgeo.geocaching.settings.Settings; -import cgeo.geocaching.ui.Formatter; +import cgeo.geocaching.utils.Formatter; import cgeo.geocaching.utils.LeastRecentlyUsedMap; import cgeo.geocaching.utils.Log; diff --git a/main/src/cgeo/geocaching/connector/gc/UncertainProperty.java b/main/src/cgeo/geocaching/connector/gc/UncertainProperty.java new file mode 100644 index 0000000..71adcbd --- /dev/null +++ b/main/src/cgeo/geocaching/connector/gc/UncertainProperty.java @@ -0,0 +1,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); + } + +} |
