14
14
@ Getter
15
15
public class MultiResponse <T > extends Response {
16
16
17
-
18
17
private Content <T > data ;
19
18
20
19
@ Setter
@@ -24,13 +23,15 @@ public static class Content<T>{
24
23
private Collection <T > list ;
25
24
}
26
25
26
+ public MultiResponse () {
27
+ this .data = new Content <>();
28
+ }
29
+
27
30
public static <T > MultiResponse <T > of (Collection <T > data , long total ) {
28
31
MultiResponse <T > multiResponse = new MultiResponse <>();
29
32
multiResponse .setSuccess (true );
30
- Content <T > content = new Content <>();
31
- content .setTotal (total );
32
- content .setList (data );
33
- multiResponse .setData (content );
33
+ multiResponse .getData ().setTotal (total );
34
+ multiResponse .getData ().setList (data );
34
35
return multiResponse ;
35
36
}
36
37
@@ -43,10 +44,6 @@ public static <T> MultiResponse<T> of(Page<T> page) {
43
44
public static <T > MultiResponse <T > empty () {
44
45
MultiResponse <T > multiResponse = new MultiResponse <>();
45
46
multiResponse .setSuccess (true );
46
- multiResponse .setData (null );
47
- Content <T > content = new Content <>();
48
- content .setTotal (0 );
49
- content .setList (null );
50
47
return multiResponse ;
51
48
}
52
49
@@ -58,9 +55,8 @@ public static <T> MultiResponse<T> of(Collection<T> data) {
58
55
if (data !=null ){
59
56
total = data .size ();
60
57
}
61
- Content <T > content = new Content <>();
62
- content .setTotal (total );
63
- content .setList (data );
58
+ multiResponse .getData ().setTotal (total );
59
+ multiResponse .getData ().setList (data );
64
60
return multiResponse ;
65
61
}
66
62
0 commit comments