summaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/AthensDomain.java
blob: eb8b5c5256b62d2b3f94eba1648b0e1d48b2fc22 (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
// 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.identifiers;

/**
 * @author smorgrav
 */
public class AthensDomain extends Identifier {

    public AthensDomain(String id) {
        super(id);
    }

    public boolean isTopLevelDomain() {
        return !id().contains(".");
    }

    public AthensDomain getParent() {
        return new AthensDomain(id().substring(0, lastDot()));
    }

    public String getName() {
        return id().substring(lastDot() + 1);
    }

    private int lastDot() {
        return id().lastIndexOf('.');
    }

}