1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.bremersee.apiclient.webflux.contract.spring;
18
19 import java.util.Comparator;
20 import org.bremersee.apiclient.webflux.InvocationParameter;
21 import org.springframework.web.bind.annotation.RequestBody;
22 import org.springframework.web.bind.annotation.RequestPart;
23
24
25
26
27
28
29 class RequestBodyComparator implements Comparator<InvocationParameter> {
30
31 @Override
32 public int compare(InvocationParameter o1, InvocationParameter o2) {
33 boolean a1 = o1.hasParameterAnnotation(RequestBody.class);
34 boolean a2 = o2.hasParameterAnnotation(RequestBody.class);
35 if (a1 && a2) {
36 return 0;
37 }
38 if (a1) {
39 return -1;
40 }
41 if (a2) {
42 return 1;
43 }
44 a1 = o1.hasParameterAnnotation(RequestPart.class);
45 a2 = o2.hasParameterAnnotation(RequestPart.class);
46 if (a1 && a2) {
47 return 0;
48 }
49 if (a1) {
50 return -1;
51 }
52 if (a2) {
53 return 1;
54 }
55 return Integer.compare(o1.getIndex(), o2.getIndex());
56 }
57 }