|
1
|
|
|
/** |
|
2
|
|
|
* |
|
3
|
|
|
*/ |
|
4
|
|
|
package unicon.matthews.tenant; |
|
5
|
|
|
|
|
6
|
|
|
import java.io.Serializable; |
|
7
|
|
|
import java.util.Map; |
|
8
|
|
|
|
|
9
|
|
|
import org.apache.commons.lang3.builder.ToStringBuilder; |
|
10
|
|
|
import org.apache.commons.lang3.builder.ToStringStyle; |
|
11
|
|
|
import org.springframework.data.annotation.Id; |
|
12
|
|
|
|
|
13
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
|
14
|
|
|
import com.fasterxml.jackson.annotation.JsonInclude; |
|
15
|
|
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @author ggilbert |
|
19
|
|
|
* |
|
20
|
|
|
*/ |
|
21
|
|
|
@JsonIgnoreProperties(ignoreUnknown=true) |
|
22
|
|
|
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
|
23
|
|
|
@JsonDeserialize(builder = Tenant.Builder.class) |
|
24
|
|
|
public final class Tenant implements Serializable { |
|
25
|
|
|
private static final long serialVersionUID = 1L; |
|
26
|
|
|
|
|
27
|
|
|
@Id private String id; |
|
28
|
|
|
private String name; |
|
29
|
|
|
private String description; |
|
30
|
|
|
private Map<String, String> metadata; |
|
31
|
|
|
|
|
32
|
|
|
private Tenant() {} |
|
33
|
|
|
|
|
34
|
|
|
public String getId() { |
|
35
|
|
|
return id; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public String getName() { |
|
39
|
|
|
return name; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public String getDescription() { |
|
43
|
|
|
return description; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public Map<String, String> getMetadata() { |
|
47
|
|
|
return metadata; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
@Override |
|
51
|
|
|
public String toString() { |
|
52
|
|
|
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
@Override |
|
56
|
|
|
public int hashCode() { |
|
57
|
|
|
final int prime = 31; |
|
58
|
|
|
int result = 1; |
|
59
|
|
|
result = prime * result + ((description == null) ? 0 : description.hashCode()); |
|
60
|
|
|
result = prime * result + ((id == null) ? 0 : id.hashCode()); |
|
61
|
|
|
result = prime * result + ((metadata == null) ? 0 : metadata.hashCode()); |
|
62
|
|
|
result = prime * result + ((name == null) ? 0 : name.hashCode()); |
|
63
|
|
|
return result; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
@Override |
|
67
|
|
|
public boolean equals(Object obj) { |
|
68
|
|
|
if (this == obj) |
|
69
|
|
|
return true; |
|
70
|
|
|
if (obj == null) |
|
71
|
|
|
return false; |
|
72
|
|
|
if (getClass() != obj.getClass()) |
|
73
|
|
|
return false; |
|
74
|
|
|
Tenant other = (Tenant) obj; |
|
75
|
|
|
if (description == null) { |
|
76
|
|
|
if (other.description != null) |
|
77
|
|
|
return false; |
|
78
|
|
|
} else if (!description.equals(other.description)) |
|
79
|
|
|
return false; |
|
80
|
|
|
if (id == null) { |
|
81
|
|
|
if (other.id != null) |
|
82
|
|
|
return false; |
|
83
|
|
|
} else if (!id.equals(other.id)) |
|
84
|
|
|
return false; |
|
85
|
|
|
if (metadata == null) { |
|
86
|
|
|
if (other.metadata != null) |
|
87
|
|
|
return false; |
|
88
|
|
|
} else if (!metadata.equals(other.metadata)) |
|
89
|
|
|
return false; |
|
90
|
|
|
if (name == null) { |
|
91
|
|
|
if (other.name != null) |
|
92
|
|
|
return false; |
|
93
|
|
|
} else if (!name.equals(other.name)) |
|
94
|
|
|
return false; |
|
95
|
|
|
return true; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public static class Builder { |
|
99
|
|
|
private Tenant _tenant = new Tenant(); |
|
100
|
|
|
|
|
101
|
|
|
public Builder withId(String id) { |
|
102
|
|
|
_tenant.id = id; |
|
103
|
|
|
return this; |
|
104
|
|
|
} |
|
105
|
|
|
public Builder withName(String name) { |
|
106
|
|
|
_tenant.name = name; |
|
107
|
|
|
return this; |
|
108
|
|
|
} |
|
109
|
|
|
public Builder withDescription(String description) { |
|
110
|
|
|
_tenant.description = description; |
|
111
|
|
|
return this; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public Builder withMetadata(Map<String, String> metadata) { |
|
115
|
|
|
_tenant.metadata = metadata; |
|
116
|
|
|
return this; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public Tenant build() { |
|
120
|
|
|
return _tenant; |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
} |
|
125
|
|
|
|