aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/tenant/TenantContact.java
blob: 482bb26bcf9d309b7ae2256c0d4db6176f40dcb6 (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
// Copyright Yahoo. 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;

/**
 * @author ogronnesby
 */
public class TenantContact {
    private final String name;
    private final Email email;
    private final String phone;

    private TenantContact(String name, Email email, String phone) {
        this.name = Objects.requireNonNull(name);
        this.email = Objects.requireNonNull(email);
        this.phone = Objects.requireNonNull(phone);
    }

    public static TenantContact from(String name, Email email, String phone) {
        return new TenantContact(name, email, phone);
    }

    public static TenantContact from(String name, Email email) {
        return TenantContact.from(name, email, "");
    }

    public static TenantContact empty() {
        return new TenantContact("", Email.empty(), "");
    }

    public String name() { return name; }
    public Email email() { return email; }
    public String phone() { return phone; }

    public TenantContact withName(String name) {
        return new TenantContact(name, email, phone);
    }

    public TenantContact withEmail(Email email) {
        return new TenantContact(name, email, phone);
    }

    public TenantContact withPhone(String phone) {
        return new TenantContact(name, email, phone);
    }

    @Override
    public String toString() {
        return "TenantContact{" +
                "name='" + name + '\'' +
                ", email='" + email + '\'' +
                ", phone='" + phone + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TenantContact that = (TenantContact) o;
        return Objects.equals(name, that.name) && Objects.equals(email, that.email) && Objects.equals(phone, that.phone);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, email, phone);
    }
}