blob: 191ff81b514cd5eaeae573ae57c561d672cc8ef7 (
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
|
// Copyright Vespa.ai. 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 data field of a DNS record (RDATA).
*
* E.g. this may be an IP address for A records, or a FQDN for CNAME records.
*
* @author mpolden
*/
public record RecordData(String data) implements Comparable<RecordData> {
public RecordData {
Objects.requireNonNull(data, "data cannot be null");
}
public String asString() {
return data;
}
@Override
public String toString() {
return data;
}
/** Create data containing the given data */
public static RecordData from(String data) {
return new RecordData(data);
}
/** Create a new record and append a trailing dot to given data, if missing */
public static RecordData fqdn(String data) {
return from(data.endsWith(".") ? data : data + ".");
}
@Override
public int compareTo(RecordData that) {
return this.data.compareTo(that.data);
}
}
|