aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/organization/Contact.java
blob: ac532378923c1617c30d4f3d018a70b5f1ec7cbe (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// 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.organization;

import java.net.URI;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

/**
 * Contact information for a tenant.
 *
 * @author mpolden
 */
public class Contact {

    private final URI url;
    private final URI propertyUrl;
    private final URI issueTrackerUrl;
    private final List<List<String>> persons;
    private final String queue;
    private final Optional<String> component;

    public Contact(URI url, URI propertyUrl, URI issueTrackerUrl, List<List<String>> persons, String queue, Optional<String> component) {
        this.propertyUrl = Objects.requireNonNull(propertyUrl, "propertyUrl must be non-null");
        this.url = Objects.requireNonNull(url, "url must be non-null");
        this.issueTrackerUrl = Objects.requireNonNull(issueTrackerUrl, "issueTrackerUrl must be non-null");
        this.persons = List.copyOf(Objects.requireNonNull(persons, "persons must be non-null"));
        this.queue = queue;
        this.component = component;
    }

    /** URL to this */
    public URI url() {
        return url;
    }

    /** URL to information about this property */
    public URI propertyUrl() {
        return propertyUrl;
    }

    /** URL to this contacts's issue tracker */
    public URI issueTrackerUrl() {
        return issueTrackerUrl;
    }

    /** Nested list of persons representing this. First level represents that person's rank in the corporate dystopia. */
    public List<List<String>> persons() {
        return persons;
    }

    public String queue() {
        return queue;
    }

    public Optional<String> component() {
        return component;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Contact contact = (Contact) o;
        return Objects.equals(url, contact.url) &&
               Objects.equals(propertyUrl, contact.propertyUrl) &&
               Objects.equals(issueTrackerUrl, contact.issueTrackerUrl) &&
               Objects.equals(persons, contact.persons) &&
               Objects.equals(queue, contact.queue) &&
               Objects.equals(component, contact.component);
    }

    @Override
    public int hashCode() {
        return Objects.hash(url, propertyUrl, issueTrackerUrl, persons);
    }

    @Override
    public String toString() {
        return "Contact{" +
               "url=" + url +
               ", propertyUrl=" + propertyUrl +
               ", issueTrackerUrl=" + issueTrackerUrl +
               ", persons=" + persons +
               ", queue=" + queue +
                (component.isPresent() ? ", component=" + component.get() : "") +
               '}';
    }

}