aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/utils/UncertainProperty.java
blob: 2187558b6b0decdd22131c1a5a57f3955a5570d1 (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
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;
    }

}