aboutsummaryrefslogtreecommitdiffstats
path: root/config-lib/src/main/java/com/yahoo/config/UrlReference.java
blob: 518da80455db53513607eb975e80bbd4592009cb (plain) (blame)
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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;

import java.util.Objects;

/**
 * Similar to {@link FileReference}, holds either a URL or a file path to the
 * downloaded file depending on state.
 *
 * @author lesters
 */
public final class UrlReference {

    /** Either the url or, if downloaded, the absolute path to the downloaded file. */
    private final String value;

    public UrlReference(String value) {
        this.value = Objects.requireNonNull(value);
    }

    public String value() {
        return value;
    }

    public static UrlReference valueOf(String value) {
        return new UrlReference(value);
    }

    @Override
    public int hashCode() {
        return value.hashCode();
    }

    @Override
    public boolean equals(Object other) {
        return other instanceof UrlReference &&
                value.equals(((UrlReference)other).value);
    }

    @Override
    public String toString() {
        return "url '" + value + "'";
    }

}