blob: e2548a7f283a4208d06f6a4c62470737e989c757 (
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
|
// Copyright Yahoo. 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).
*
* @author mpolden
*/
public record RecordName(String name) implements Comparable<RecordName> {
public RecordName {
Objects.requireNonNull(name, "name cannot be null");
}
public String asString() {
return name;
}
/** Returns whether this is a fully qualified domain name (ends in trailing dot) */
public boolean isFqdn() {
return name.endsWith(".");
}
/** Returns this as a fully qualified domain name (ends in trailing dot) */
public RecordName asFqdn() {
return isFqdn() ? this : new RecordName(name + ".");
}
@Override
public String toString() {
return name;
}
@Override
public int compareTo(RecordName that) {
return this.name.compareTo(that.name);
}
public static RecordName from(String name) {
return new RecordName(name);
}
public static RecordName fqdn(String name) {
return from(name).asFqdn();
}
}
|