summaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/zone/CloudName.java
blob: e7a6b32b36eaa5780076f6b7aeaf5a6da9be3dec (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.zone;

import org.jetbrains.annotations.NotNull;

import java.util.Objects;

/**
 * Represents a cloud provider used in a hosted Vespa system.
 *
 * @author mpolden
 */
public class CloudName implements Comparable<CloudName> {

    private final static CloudName defaultCloud = from("default");

    private final String cloud;

    private CloudName(String cloud) {
        this.cloud = cloud;
    }

    public String value() {
        return cloud;
    }

    public boolean isDefault() {
        return defaultName().equals(this);
    }

    public static CloudName defaultName() {
        return defaultCloud;
    }

    public static CloudName from(String cloud) {
        return new CloudName(cloud);
    }

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

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

    @Override
    public String toString() {
        return cloud;
    }

    @Override
    public int compareTo(@NotNull CloudName o) {
        return cloud.compareTo(o.cloud);
    }

}