22
33import com .google .gson .Gson ;
44import com .google .gson .reflect .TypeToken ;
5+ import org .jetbrains .annotations .NotNull ;
56
67import java .net .http .HttpResponse ;
78import java .nio .ByteBuffer ;
89import java .nio .charset .StandardCharsets ;
910import java .util .List ;
11+ import java .util .Objects ;
1012import java .util .concurrent .CompletableFuture ;
1113import java .util .concurrent .CompletionException ;
1214import java .util .concurrent .CompletionStage ;
@@ -31,12 +33,18 @@ public class APIResponse<Datatype> {
3133
3234 /**
3335 * Create a BodyHandler for APIResponse
34- * @param gson gson instance
35- * @param token type token of the response data
36+ *
37+ * @param client exaroton client
38+ * @param gson gson instance
39+ * @param token type token of the response data
40+ * @param <T> response data type
3641 * @return BodyHandler
37- * @param <T> response data type
3842 */
39- public static <T > HttpResponse .BodyHandler <APIResponse <T >> bodyHandler (ExarotonClient client , Gson gson , TypeToken <APIResponse <T >> token ) {
43+ public static <T > HttpResponse .BodyHandler <APIResponse <T >> bodyHandler (
44+ @ NotNull ExarotonClient client ,
45+ @ NotNull Gson gson ,
46+ @ NotNull TypeToken <APIResponse <T >> token
47+ ) {
4048 return responseInfo -> new BodySubscriber <>(client , gson , token );
4149 }
4250
@@ -81,10 +89,14 @@ private static final class BodySubscriber<T> implements HttpResponse.BodySubscri
8189 private final TypeToken <APIResponse <T >> token ;
8290 private final HttpResponse .BodySubscriber <String > parent ;
8391
84- private BodySubscriber (ExarotonClient client , Gson gson , TypeToken <APIResponse <T >> token ) {
85- this .client = client ;
86- this .gson = gson ;
87- this .token = token ;
92+ private BodySubscriber (
93+ @ NotNull ExarotonClient client ,
94+ @ NotNull Gson gson ,
95+ @ NotNull TypeToken <APIResponse <T >> token
96+ ) {
97+ this .client = Objects .requireNonNull (client );
98+ this .gson = Objects .requireNonNull (gson );
99+ this .token = Objects .requireNonNull (token );
88100 this .parent = HttpResponse .BodySubscribers .ofString (StandardCharsets .UTF_8 );
89101 }
90102
0 commit comments