aboutsummaryrefslogtreecommitdiffstats
path: root/orchestrator-restapi/src/main/java/com/yahoo/vespa/orchestrator/restapi/wire/BatchHostSuspendRequest.java
blob: 3dc28f532173dc336500f9c4dfe4afb62753124d (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.orchestrator.restapi.wire;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import javax.annotation.concurrent.Immutable;
import java.util.Collections;
import java.util.List;

@Immutable
public class BatchHostSuspendRequest {
    public static final String PARENT_HOSTNAME_FIELD = "parentHostname";
    public static final String HOSTNAMES_FIELD = "hostnames";

    public final String parentHostname;
    public final List<String> hostnames;

    @JsonCreator
    public BatchHostSuspendRequest(
            @JsonProperty(PARENT_HOSTNAME_FIELD) String parentHostname,
            @JsonProperty(HOSTNAMES_FIELD) List<String> hostnames) {
        this.parentHostname = parentHostname;
        this.hostnames = Collections.unmodifiableList(hostnames);
    }

    /**
     * @return The hostname of the parent of the hostnames, if applicable, which can be used for debugging.
     */
    @JsonProperty(PARENT_HOSTNAME_FIELD)
    public String getParentHostname() {
        return parentHostname;
    }

    @JsonProperty(HOSTNAMES_FIELD)
    public List<String> getHostnames() {
        return hostnames;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        BatchHostSuspendRequest that = (BatchHostSuspendRequest) o;

        if (parentHostname != null ? !parentHostname.equals(that.parentHostname) : that.parentHostname != null)
            return false;
        return hostnames != null ? hostnames.equals(that.hostnames) : that.hostnames == null;

    }

    @Override
    public int hashCode() {
        int result = parentHostname != null ? parentHostname.hashCode() : 0;
        result = 31 * result + (hostnames != null ? hostnames.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "BatchHostSuspendRequest{" +
                "parentHostname=" + parentHostname +
                ", hostnames=" + hostnames +
                '}';
    }
}