1919 */
2020package capital .scalable .restdocs .example .items ;
2121
22- import static com .fasterxml .jackson .annotation .JsonTypeInfo .As .PROPERTY ;
23- import static com .fasterxml .jackson .annotation .JsonTypeInfo .Id .NAME ;
24-
2522import javax .validation .Valid ;
26- import javax .validation .constraints .DecimalMax ;
27- import javax .validation .constraints .DecimalMin ;
28- import javax .validation .constraints .Max ;
29- import javax .validation .constraints .Min ;
3023import javax .validation .constraints .NotBlank ;
3124import javax .validation .constraints .NotEmpty ;
32- import javax .validation .constraints .NotNull ;
33- import javax .validation .constraints .Size ;
34- import java .math .BigDecimal ;
3525import java .util .List ;
3626
3727import com .fasterxml .jackson .annotation .JsonIgnore ;
38- import com .fasterxml .jackson .annotation .JsonSubTypes ;
39- import com .fasterxml .jackson .annotation .JsonTypeInfo ;
4028import lombok .AllArgsConstructor ;
41- import lombok .NoArgsConstructor ;
42- import lombok .Value ;
4329
4430/**
4531 * Java object for a single JSON item.
@@ -60,8 +46,7 @@ class ItemResponse {
6046 * <p>
6147 * An example of JsonSubType support.
6248 *
63- * @see
64- * <a href="https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations#type-handling">
49+ * @see <a href="https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations#type-handling">
6550 * Jackson type documentation</a>
6651 */
6752 private Metadata meta ;
@@ -89,88 +74,4 @@ class ItemResponse {
8974 public String getDescription () {
9075 return desc ;
9176 }
92-
93- /**
94- * Various attributes about the item.
95- */
96- @ Value
97- public static class Attributes {
98- /**
99- * Textual attribute.
100- */
101- @ NotBlank
102- @ Size (min = 2 , max = 20 )
103- private String text ;
104- /**
105- * Integer attribute.
106- */
107- @ NotNull
108- @ Min (1 )
109- @ Max (10 )
110- private Integer number ;
111- /**
112- * Boolean attribute.
113- */
114- private Boolean bool ;
115- /**
116- * Decimal attribute.
117- */
118- @ DecimalMin ("1" )
119- @ DecimalMax ("10" )
120- private BigDecimal decimal ;
121- /**
122- * Amount attribute.
123- */
124- @ NotNull
125- private Money amount ;
126- /**
127- * Enum attribute.
128- */
129- @ NotNull
130- private EnumType enumType ;
131- }
132-
133- @ NoArgsConstructor
134- @ AllArgsConstructor
135- @ JsonTypeInfo (use = NAME , include = PROPERTY , property = "type" , visible = true )
136- @ JsonSubTypes ({
137- @ JsonSubTypes .Type (value = Metadata1 .class , name = "1" ),
138- @ JsonSubTypes .Type (value = Metadata2 .class , name = "2" )
139- })
140- static class Metadata {
141- /**
142- * Determines the type of metadata
143- */
144- @ NotBlank
145- private String type ;
146- }
147-
148- @ NoArgsConstructor
149- static class Metadata1 extends Metadata {
150- /**
151- * Tag attribute. Available only if metadata type=1
152- */
153- private String tag ;
154-
155- Metadata1 (String type , String tag ) {
156- super (type );
157- this .tag = tag ;
158- }
159- }
160-
161- static class Metadata2 extends Metadata {
162- /**
163- * Order attribute. Available only if metadata type=2
164- */
165- private Integer order ;
166-
167- Metadata2 (String type , Integer order ) {
168- super (type );
169- this .order = order ;
170- }
171- }
172-
173- enum EnumType {
174- ONE , TWO
175- }
17677}
0 commit comments