summaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/RecordName.java
blob: aa239ece5884121c9417ad26dd321a74f704896d (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
// Copyright 2017 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.dns;

import java.util.Objects;

/**
 * Represents the name field of a DNS record (NAME). This is typically a FQDN.
 *
 * @author mpolden
 */
public class RecordName {

    private final String name;

    private RecordName(String name) {
        this.name = Objects.requireNonNull(name, "name cannot be null");
    }

    public String asString() {
        return name;
    }

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

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

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

    public static RecordName from(String name) {
        return new RecordName(name);
    }

}