summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/DefaultedURL.java
blob: 0cbb0d7200b1ab267e54af3d12f6c9ba033d44aa (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
40
41
42
43
44
45
46
47
48
package se.leap.bitmaskclient;

import java.net.MalformedURLException;
import java.net.URL;

public class DefaultedURL {
    private URL DEFAULT_URL;
    private String default_url = "https://example.net";

    private URL url;

    DefaultedURL() {
        try {
            DEFAULT_URL = new URL(default_url);
            url = DEFAULT_URL;
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

    public boolean isDefault() { return url.equals(DEFAULT_URL); }

    public void setUrl(URL url) {
        this.url = url;
    }

    public String getDomain() {
        return url.getHost();
    }

    public URL getUrl() {
        return url;
    }

    @Override
    public String toString() {
        return url.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof DefaultedURL) {
            return url.equals(((DefaultedURL) o).getUrl());
        }
        return false;
    }

}