summaryrefslogtreecommitdiffstats
path: root/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/EndpointId.java
blob: f186125d09a06847c73bbb50416cd624801b9fee (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
46
47
package com.yahoo.vespa.hosted.controller.application;

import java.util.Objects;

public class EndpointId {
    private static final EndpointId DEFAULT = new EndpointId("default");

    private final String id;

    public EndpointId(String id) {
        this.id = requireNotEmpty(id);
    }

    public String id() { return id; }

    @Override
    public String toString() {
        return "EndpointId{" +
                "id='" + id + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        EndpointId that = (EndpointId) o;
        return Objects.equals(id, that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

    private static String requireNotEmpty(String input) {
        Objects.requireNonNull(input);
        if (input.isEmpty()) {
            throw new IllegalArgumentException("The value EndpointId was empty");
        }
        return input;
    }

    public static EndpointId default_() { return DEFAULT; }

    public static EndpointId of(String id) { return new EndpointId(id); }
}