aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/entity/NodeEntity.java
blob: 0b8aaf3ec2d09af2a34b96f32c785743bd99a54b (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 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.entity;

import java.util.Objects;
import java.util.Optional;

/**
 * Information about a node from a {@link EntityService}.
 *
 * @author mpolden
 */
public class NodeEntity {

    private final String hostname;
    private final Optional<String> model;
    private final Optional<String> manufacturer;
    private final Optional<String> switchHostname;

    public NodeEntity(String hostname, String model, String manufacturer, String switchHostname) {
        this.hostname = Objects.requireNonNull(hostname);
        this.model = nonBlank(model);
        this.manufacturer = nonBlank(manufacturer);
        this.switchHostname = nonBlank(switchHostname);
    }

    public String hostname() {
        return hostname;
    }

    /** The model name of this node */
    public Optional<String> model() {
        return model;
    }

    /** The manufacturer of this node */
    public Optional<String> manufacturer() {
        return manufacturer;
    }

    /** The hostname of network switch this node is connected to */
    public Optional<String> switchHostname() {
        return switchHostname;
    }

    private static Optional<String> nonBlank(String s) {
        return Optional.ofNullable(s).filter(v -> !v.isBlank());
    }

}