summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java
blob: 58ffa12e35f4ef49ffe6c72cf132375160557cdd (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 com.mapbox.mapboxsdk.style.sources;

import java.util.HashMap;

/**
 * Base Peer class for sources. see source.hpp for the other half of the peer.
 */
public abstract class Source {
    private long nativePtr;
    private boolean invalidated;

    public Source(long nativePtr) {
        this.nativePtr = nativePtr;
    }

    public Source() {
    }

    public String getId() {
        checkValidity();
        return nativeGetId();
    }

    public long getNativePtr() {
        return nativePtr;
    }

    protected native String nativeGetId();

    protected void checkValidity() {
        if (invalidated) {
            throw new RuntimeException("Layer has been invalidated. Request a new reference after adding");
        }
    }

    public final void invalidate() {
        this.invalidated = true;
    }
}