aboutsummaryrefslogtreecommitdiffstats
path: root/config-provisioning/src/main/java/com/yahoo/config/provision/HostName.java
blob: 4005e4cb09cc52539cab009e0d663db676b67960 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.provision;

import ai.vespa.http.DomainName;

import static ai.vespa.validation.Validation.require;
import static ai.vespa.validation.Validation.requireLength;

/**
 * Hostnames match {@link #domainNamePattern}, and are restricted to 64 characters in length.
 *
 * @author jonmv
 */
public class HostName extends DomainName {

    private HostName(String value) {
        super(requireLength(require( ! value.endsWith("."),
                                     value, "hostname cannot end with '.'"),
                            "hostname length", 1, 64),
              "hostname");
    }

    public static HostName of(String value) {
        return new HostName(value);
    }

}