/
DbApplicationFeature.java
233 lines (187 loc) · 5.03 KB
/
DbApplicationFeature.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
package io.featurehub.db.model;
import io.ebean.annotation.ChangeLog;
import io.ebean.annotation.Index;
import io.featurehub.mr.model.FeatureValueType;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.Lob;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.Set;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Index(
unique = true,
name = "idx_app_features",
columnNames = {"fk_app_id", "feature_key"})
@Entity
@Table(name = "fh_app_feature")
@ChangeLog
public class DbApplicationFeature extends DbVersionedBase {
private DbApplicationFeature(Builder builder) {
setParentApplication(builder.parentApplication);
setKey(builder.key);
setAlias(builder.alias);
setName(builder.name);
setSecret(builder.secret);
setLink(builder.link);
setValueType(builder.valueType);
setMetaData(builder.metaData);
setDescription(builder.description);
}
@ManyToOne(optional = false)
@JoinColumn(name = "fk_app_id")
@Column(name = "fk_app_id", nullable = false)
private DbApplication parentApplication;
@Column(name = "when_archived")
@Nullable
private LocalDateTime whenArchived;
@Column(name = "feature_key")
private String key;
private String alias;
private String name;
private boolean secret;
@Column(length = 600)
private String link;
@Column(length = 300)
private String description;
@Lob private String metaData;
@Enumerated(value = EnumType.STRING)
@Column(name = "value_type", nullable = false)
@NotNull
private FeatureValueType valueType;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "fk_feature_id")
private Set<DbFeatureValue> environmentFeatures;
@NotNull
public DbApplication getParentApplication() {
return parentApplication;
}
public void setParentApplication(@NotNull DbApplication parentApplication) {
this.parentApplication = parentApplication;
}
@NotNull
public String getKey() {
return key;
}
public void setKey(@NotNull String key) {
this.key = key;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
@NotNull
public String getName() {
return name;
}
public void setName(@NotNull String name) {
this.name = name;
}
@NotNull
public Set<DbFeatureValue> getEnvironmentFeatures() {
if (environmentFeatures == null) {
environmentFeatures = new HashSet<>();
}
return environmentFeatures;
}
public void setEnvironmentFeatures(@NotNull Set<DbFeatureValue> environmentFeatures) {
this.environmentFeatures = environmentFeatures;
}
public boolean isSecret() {
return secret;
}
public void setSecret(boolean secret) {
this.secret = secret;
}
public @NotNull FeatureValueType getValueType() {
return valueType;
}
public void setValueType(@NotNull FeatureValueType valueType) {
this.valueType = valueType;
}
public String getLink() {
return link;
}
public LocalDateTime getWhenArchived() {
return whenArchived;
}
public void setWhenArchived(LocalDateTime whenArchived) {
this.whenArchived = whenArchived;
}
public void setLink(String link) {
this.link = link;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getMetaData() {
return metaData;
}
public void setMetaData(String metaData) {
this.metaData = metaData;
}
public static final class Builder {
public String metaData;
public String description;
private DbApplication parentApplication;
private String key;
private String alias;
private String name;
private boolean secret;
private String link;
private FeatureValueType valueType;
public Builder() {}
public Builder parentApplication(DbApplication val) {
parentApplication = val;
return this;
}
public Builder description(String val) {
description = val;
return this;
}
public Builder metaData(String val) {
metaData = val;
return this;
}
public Builder key(String val) {
key = val;
return this;
}
public Builder alias(String val) {
alias = val;
return this;
}
public Builder name(String val) {
name = val;
return this;
}
public Builder secret(boolean val) {
secret = val;
return this;
}
public Builder link(String val) {
link = val;
return this;
}
public Builder valueType(FeatureValueType val) {
valueType = val;
return this;
}
public DbApplicationFeature build() {
return new DbApplicationFeature(this);
}
}
}