package cgeo.geocaching.utils; import cgeo.geocaching.connector.gc.Tile; /** * Property with certainty. When merging properties, the one with higher certainty wins. * * @param */ public class UncertainProperty { 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 getMergedProperty(final UncertainProperty 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 UncertainProperty getMergedProperty(UncertainProperty property, UncertainProperty otherProperty) { if (null == property) { return otherProperty; } return property.getMergedProperty(otherProperty); } }