-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
AnnotatedSpec.java
190 lines (158 loc) · 4.46 KB
/
AnnotatedSpec.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
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fabric8.crd.example.annotated;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import io.fabric8.generator.annotation.Default;
import io.fabric8.generator.annotation.Format;
import io.fabric8.generator.annotation.Max;
import io.fabric8.generator.annotation.Min;
import io.fabric8.generator.annotation.Nullable;
import io.fabric8.generator.annotation.Pattern;
import io.fabric8.generator.annotation.Required;
import io.fabric8.generator.annotation.ValidationRule;
import lombok.Data;
import java.time.ZonedDateTime;
@Data
public class AnnotatedSpec {
@JsonProperty("from-field")
@JsonPropertyDescription("from-field-description")
private String field;
private int foo;
@JsonProperty
private String unnamed;
private int min;
private int max;
private String singleDigit;
private String nullable;
private String defaultValue;
@Default("my-value2")
private String defaultValue2;
@Required
private boolean emptySetter;
@Required
private boolean emptySetter2;
private AnnotatedEnum anEnum;
@javax.validation.constraints.Min(0) // a non-string value attribute
private int sizedField;
private String bool;
private String num;
private String numInt;
private String numFloat;
private ZonedDateTime issuedAt;
private String password;
@JsonIgnore
private int ignoredFoo;
private boolean ignoredBar;
@ValidationRule(value = "self.startwith('prefix-')", message = "kubernetesValidationRule must start with prefix 'prefix-'")
private String kubernetesValidationRule;
@ValidationRule("first.rule")
@ValidationRule("second.rule")
@ValidationRule(value = "third.rule", reason = "FieldValueForbidden")
private String kubernetesValidationRules;
@JsonProperty("from-getter")
@JsonPropertyDescription("from-getter-description")
@Required
public int getFoo() {
return foo;
}
public int getIgnoredFoo() {
return ignoredFoo;
}
@JsonIgnore
public boolean getIgnoredBar() {
return ignoredBar;
}
@Max(5.0)
public int getMax() {
return 1;
}
@Min(-5)
public int getMin() {
return 1;
}
@Format("password")
public String getPassword() {
return password;
}
@Pattern("\\b[1-9]\\b")
public String getSingleDigit() {
return "1";
}
@Nullable
public String getNullable() {
return null;
}
@Default("my-value")
public String getDefaultValue() {
return "foo";
}
@JsonProperty
public void setEmptySetter(boolean emptySetter) {
this.emptySetter = emptySetter;
}
@JsonProperty
public void setEmptySetter2(boolean emptySetter2) {
this.emptySetter2 = emptySetter2;
}
@JsonFormat(shape = JsonFormat.Shape.BOOLEAN)
public String getBool() {
return bool;
}
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
public String getNum() {
return num;
}
@JsonFormat(shape = JsonFormat.Shape.NUMBER_FLOAT)
public String getNumFloat() {
return numFloat;
}
@JsonFormat(shape = JsonFormat.Shape.NUMBER_INT)
public String getNumInt() {
return numInt;
}
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssVV")
public java.time.ZonedDateTime getIssuedAt() {
return issuedAt;
}
public enum AnnotatedEnum {
non("N"),
@JsonProperty("oui")
es("O"),
@JsonIgnore
Maybe("Maybe");
private final String abbreviation;
AnnotatedEnum(String abbreviation) {
this.abbreviation = abbreviation;
}
public String getAbbreviation() {
return abbreviation;
}
public static AnnotatedEnum SIM = es;
public AnotherEnum one = AnotherEnum.ONE;
public AnotherEnum getOne() {
return one;
}
public void setOne(AnotherEnum one) {
this.one = one;
}
}
public enum AnotherEnum {
ONE
}
}