/
Contact.java
116 lines (92 loc) · 2.74 KB
/
Contact.java
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
/*
* Copyright (c) 2017 Otávio Santana and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
*
* You may elect to redistribute this code under either of these licenses.
*
* Contributors:
*
* Otavio Santana
*/
package jakarta.nosql.tck.entities;
import jakarta.nosql.mapping.Column;
import jakarta.nosql.mapping.Embeddable;
import java.util.Objects;
@Embeddable
public class Contact {
@Column
private ContactType type;
@Column("contact_name")
private String name;
@Column
private String information;
Contact() {
}
private Contact(ContactType type, String name, String information) {
this.type = type;
this.name = name;
this.information = information;
}
public ContactType getType() {
return type;
}
public String getName() {
return name;
}
public String getInformation() {
return information;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Contact contact = (Contact) o;
return type == contact.type &&
Objects.equals(name, contact.name) &&
Objects.equals(information, contact.information);
}
@Override
public int hashCode() {
return Objects.hash(type, name, information);
}
@Override
public String toString() {
return "Contact{" + "type=" + type +
", name='" + name + '\'' +
", information='" + information + '\'' +
'}';
}
public static ContactBuilder builder() {
return new ContactBuilder();
}
public static class ContactBuilder {
private ContactType type;
private String name;
private String information;
private ContactBuilder() {
}
public ContactBuilder withType(ContactType type) {
this.type = type;
return this;
}
public ContactBuilder withName(String name) {
this.name = name;
return this;
}
public ContactBuilder withInformation(String information) {
this.information = information;
return this;
}
public Contact build() {
return new Contact(type, name, information);
}
}
}