This repository was archived by the owner on May 11, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathProvisioning.java
More file actions
381 lines (312 loc) · 8.82 KB
/
Copy pathProvisioning.java
File metadata and controls
381 lines (312 loc) · 8.82 KB
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
package source;
import io.jooby.Context;
import io.jooby.FileUpload;
import io.jooby.FlashMap;
import io.jooby.Formdata;
import io.jooby.Multipart;
import io.jooby.QueryString;
import io.jooby.Session;
import io.jooby.StatusCode;
import io.jooby.annotations.CookieParam;
import io.jooby.annotations.DELETE;
import io.jooby.annotations.FlashParam;
import io.jooby.annotations.FormParam;
import io.jooby.annotations.GET;
import io.jooby.annotations.HeaderParam;
import io.jooby.annotations.POST;
import io.jooby.annotations.Path;
import io.jooby.annotations.PathParam;
import io.jooby.annotations.QueryParam;
import javax.annotation.Nonnull;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Path("/p")
public class Provisioning {
@GET("/noarg")
public String noarg() {
return "noarg";
}
@GET("/context")
public String context(Context ctx) {
assertTrue(ctx instanceof Context);
return "ctx";
}
@GET("/contextFirst")
public String contextFirst(Context ctx, QueryString queryString) {
assertTrue(ctx instanceof Context);
assertTrue(queryString instanceof QueryString);
return "ctxfirst";
}
@GET("/queryString")
public String queryString(QueryString queryString) {
assertTrue(queryString instanceof QueryString);
return "queryString";
}
@GET("/queryStringOptional")
public String queryStringOptional(Optional<QueryString> queryString) {
queryString.ifPresent(it -> assertTrue(it instanceof QueryString));
return "queryStringOptional:" + queryString.isPresent();
}
@GET("/formdata")
public String formdata(Formdata value) {
assertTrue(value instanceof Formdata);
return "formdata";
}
@GET("/multipart")
public String multipart(Multipart value) {
assertTrue(value instanceof Multipart);
return "multipart";
}
@GET("/flashMap")
public String flashMap(FlashMap value) {
assertTrue(value instanceof FlashMap);
return "flashMap";
}
@GET("/session")
public String session(Session value) {
assertTrue(value instanceof Session);
return "session";
}
@GET("/sessionOrNull")
public String sessionOrNull(Optional<Session> session) {
return "session:" + session.isPresent();
}
@GET("/pathParam/{p1}")
public String pathParam(@PathParam String p1) {
return p1;
}
@GET("/bytePathParam/{p1}")
public String bytePathParam(@PathParam byte p1) {
return Integer.toString(p1);
}
@GET("/intPathParam/{p1}")
public String intPathParam(@PathParam int p1) {
return Integer.toString(p1);
}
@GET("/longPathParam/{p1}")
public String longPathParam(@PathParam long p1) {
return Long.toString(p1);
}
@GET("/floatPathParam/{p1}")
public String floatPathParam(@PathParam float p1) {
return Float.toString(p1);
}
@GET("/doublePathParam/{p1}")
public String doublePathParam(@PathParam double p1) {
return Double.toString(p1);
}
@GET("/booleanPathParam/{p1}")
public String booleanPathParam(@PathParam boolean p1) {
return Boolean.toString(p1);
}
@GET("/optionalStringPathParam/{p1}")
public String optionalStringPathParam(@PathParam Optional<String> p1) {
return p1.toString();
}
@GET("/optionalIntPathParam/{p1}")
public String optionalIntPathParam(@PathParam Optional<Integer> p1) {
return p1.toString();
}
@GET("/javaBeanPathParam/{foo}")
public String javaBeanPathParam(@PathParam JavaBeanParam param) {
return param.toString();
}
@GET("/listStringPathParam/{values}")
public String listStringPathParam(@PathParam List<String> values) {
return values.toString();
}
@GET("/listDoublePathParam/{values}")
public String listDoublePathParam(@PathParam List<Double> values) {
return values.toString();
}
@GET("/listBeanPathParam/{foo}")
public String listBeanPathParam(@PathParam List<JavaBeanParam> bean) {
return bean.toString();
}
@GET("/setStringPathParam/{values}")
public String setStringPathParam(@PathParam Set<String> values) {
return values.toString();
}
@GET("/setDoublePathParam/{values}")
public String setDoublePathParam(@PathParam Set<Double> values) {
return values.toString();
}
@GET("/setBeanPathParam/{foo}")
public String setBeanPathParam(@PathParam Set<JavaBeanParam> bean) {
return bean.toString();
}
@GET("/enumParam/{letter}")
public String enumParam(@PathParam EnumParam letter) {
return letter.name();
}
@GET("/optionalEnumParam/{letter}")
public String optionalEnumParam(@PathParam Optional<EnumParam> letter) {
return letter.toString();
}
@GET("/listEnumParam/{letter}")
public String listEnumParam(@PathParam List<EnumParam> letter) {
return letter.toString();
}
@GET("/primitiveWrapper/{value}")
public String primitiveWrapper(@PathParam Integer value) {
return String.valueOf(value);
}
@GET("/queryParam")
public String queryParam(@QueryParam String q) {
return q;
}
@GET("/cookieParam")
public String cookieParam(@CookieParam String c) {
return c;
}
@GET("/headerParam")
public String headerParam(@HeaderParam Instant instant) {
return String.valueOf(instant.toEpochMilli());
}
@GET("/flashParam")
public String flashParam(@FlashParam String message) {
return message;
}
@GET("/formParam")
public String formParam(@FormParam String name) {
return name;
}
@GET("/parameters/{path}")
public String parameters(@PathParam String path, Context ctx, @QueryParam int offset, @QueryParam JavaBeanParam javaBean) {
return path + ctx + offset + javaBean;
}
@GET("/fileParam")
public String fileParam(FileUpload file) {
return file.toString();
}
@GET("/fileParams")
public String fileParams(List<FileUpload> file) {
return file.toString();
}
@GET("/uuidParam")
public String uuidParam(@QueryParam UUID value) {
return value.toString();
}
@GET("/bigDecimalParam")
public String bigDecimalParam(@QueryParam BigDecimal value) {
return value.toString();
}
@GET("/bigIntegerParam")
public String bigIntegerParam(@QueryParam BigInteger value) {
return value.toString();
}
@GET("/charsetParam")
public String charsetParam(@QueryParam Charset value) {
return value.toString();
}
@GET("/pathFormParam")
public String pathFormParam(@FormParam java.nio.file.Path file) {
return file.toString();
}
@GET("/returnByte")
public byte returnByte() {
return 8;
}
@GET("/returnShort")
public short returnShort() {
return 8;
}
@GET("/returnInteger")
public int returnInteger() {
return 7;
}
@GET("/returnLong")
public long returnLong() {
return 9;
}
@GET("/returnFloat")
public float returnFloat() {
return 7.9f;
}
@GET("/returnChar")
public char returnChar() {
return 'c';
}
@GET("/returnDouble")
public double returnDouble() {
return 8.9;
}
@GET("/returnStatusCode")
public StatusCode returnStatusCode() {
return StatusCode.NO_CONTENT;
}
@GET("/statusCode")
public StatusCode statusCode(@QueryParam StatusCode statusCode, @QueryParam String q) {
return statusCode;
}
@DELETE("/noContent")
public void noContent() {
}
@GET("/sideEffect")
public void sideEffect(Context ctx) {
ctx.send(StatusCode.CREATED);
}
@POST
@Path("/bodyStringParamNullable")
public String bodyStringParamNullable(String body) {
return body;
}
@POST
@Path("/bodyStringParam")
public String bodyStringParam(@Nonnull String body) {
return body;
}
@POST
@Path("/bodyBytesParam")
public String bodyBytesParam(byte[] body) {
return new String(body, StandardCharsets.UTF_8);
}
@POST
@Path("/bodyInputStreamParam")
public String bodyInputStreamParam(InputStream body) {
assertTrue(body instanceof InputStream);
return body.toString();
}
@POST
@Path("/bodyChannelParam")
public String bodyChannelParam(ReadableByteChannel body) {
assertTrue(body instanceof ReadableByteChannel);
return body.toString();
}
@POST
@Path("/bodyBeanParam")
public String bodyBeanParam(JavaBeanParam body) {
return body.toString();
}
@POST
@Path("/bodyIntParam")
public int bodyIntParam(int body) {
return body;
}
@POST
@Path("/bodyOptionalIntParam")
public Optional<Integer> bodyOptionalIntParam(Optional<Integer> body) {
return body;
}
@POST
@Path("/bodyMapParam")
public Map<String, Object> bodyMapParam(Map<String, Object> json) {
return json;
}
@POST
@Path("/bodyCustomGenericParam")
public CustomGenericType<String> bodyCustomGenericParam(CustomGenericType<String> body) {
return body;
}
}