aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/tenant/TenantInfo.java
blob: 81c08e1083ba5984793e37cf16156897f659ae13 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.tenant;

import java.util.Objects;

/**
 * Tenant information beyond technical tenant id and user authorizations.
 *
 * This info is used to capture generic support information and invoiced billing information.
 *
 * All fields are non null but strings can be empty
 *
 * @author smorgrav
 */
public class TenantInfo {
    private final String name;
    private final String email;
    private final String website;
    private final String contactName;
    private final String contactEmail;
    private final String invoiceEmail;
    private final TenantInfoAddress address;
    private final TenantInfoBillingContact billingContact;

    TenantInfo(String name, String email, String website, String contactName, String contactEmail,
               String invoiceEmail, TenantInfoAddress address, TenantInfoBillingContact billingContact) {
        this.name = Objects.requireNonNull(name);
        this.email = Objects.requireNonNull(email);
        this.website = Objects.requireNonNull(website);
        this.contactName = Objects.requireNonNull(contactName);
        this.contactEmail = Objects.requireNonNull(contactEmail);
        this.invoiceEmail = Objects.requireNonNull(invoiceEmail);
        this.address = Objects.requireNonNull(address);
        this.billingContact = Objects.requireNonNull(billingContact);
    }

    public static final TenantInfo EMPTY = new TenantInfo("","","", "", "", "",
            TenantInfoAddress.EMPTY, TenantInfoBillingContact.EMPTY);

    public String name() {
        return name;
    }

    public String email() {
        return email;
    }

    public String website() {
        return website;
    }

    public String contactName() {
        return contactName;
    }

    public String contactEmail() {
        return contactEmail;
    }

    public String invoiceEmail() {
        return invoiceEmail;
    }

    public TenantInfoAddress address() {
        return address;
    }

    public TenantInfoBillingContact billingContact() {
        return billingContact;
    }

    public TenantInfo withName(String newName) {
        return new TenantInfo(newName, email, website, contactName, contactEmail, invoiceEmail, address, billingContact);
    }

    public TenantInfo withEmail(String newEmail) {
        return new TenantInfo(name, newEmail, website, contactName, contactEmail, invoiceEmail, address, billingContact);
    }

    public TenantInfo withWebsite(String newWebsite) {
        return new TenantInfo(name, email, newWebsite, contactName, contactEmail, invoiceEmail, address, billingContact);
    }

    public TenantInfo withContactName(String newContactName) {
        return new TenantInfo(name, email, website, newContactName, contactEmail, invoiceEmail, address, billingContact);
    }

    public TenantInfo withContactEmail(String newContactEmail) {
        return new TenantInfo(name, email, website, contactName, newContactEmail, invoiceEmail, address, billingContact);
    }

    public TenantInfo withInvoiceEmail(String newInvoiceEmail) {
        return new TenantInfo(name, email, website, contactName, contactEmail, newInvoiceEmail, address, billingContact);
    }

    public TenantInfo withAddress(TenantInfoAddress newAddress) {
        return new TenantInfo(name, email, website, contactName, contactEmail, invoiceEmail, newAddress, billingContact);
    }

    public TenantInfo withBillingContact(TenantInfoBillingContact newBillingContact) {
        return new TenantInfo(name, email, website, contactName, contactEmail, invoiceEmail, address, newBillingContact);
    }

    public boolean isEmpty() {
        return this.equals(EMPTY);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TenantInfo that = (TenantInfo) o;
        return name.equals(that.name) &&
                email.equals(that.email) &&
                website.equals(that.website) &&
                contactName.equals(that.contactName) &&
                contactEmail.equals(that.contactEmail) &&
                invoiceEmail.equals(that.invoiceEmail) &&
                address.equals(that.address) &&
                billingContact.equals(that.billingContact);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, email, website, contactName, contactEmail, invoiceEmail, address, billingContact);
    }
}