Skip to content

Commit 728478e

Browse files
committed
- fixes missing nonnull nullable annotations
1 parent 1722c48 commit 728478e

15 files changed

Lines changed: 86 additions & 24 deletions

‎src/main/java/com/microsoft/graph/content/MSBatchRequestContent.java‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import java.util.Map;
88
import java.util.concurrent.ThreadLocalRandom;
99

10+
import javax.annotation.Nullable;
11+
import javax.annotation.Nonnull;
12+
1013
import com.google.gson.JsonArray;
1114
import com.google.gson.JsonElement;
1215
import com.google.gson.JsonObject;
@@ -30,7 +33,7 @@ public class MSBatchRequestContent {
3033
*
3134
* @param batchRequestStepsArray List of batch steps for batching
3235
*/
33-
public MSBatchRequestContent(final List<MSBatchRequestStep> batchRequestStepsArray) {
36+
public MSBatchRequestContent(@Nonnull final List<MSBatchRequestStep> batchRequestStepsArray) {
3437
if (batchRequestStepsArray.size() > MAX_NUMBER_OF_REQUESTS)
3538
throw new IllegalArgumentException("Number of batch request steps cannot exceed " + MAX_NUMBER_OF_REQUESTS);
3639

@@ -52,7 +55,7 @@ public MSBatchRequestContent() {
5255
* @return true or false based on addition or no addition of batch request step
5356
* given
5457
*/
55-
public boolean addBatchRequestStep(final MSBatchRequestStep batchRequestStep) {
58+
public boolean addBatchRequestStep(@Nonnull final MSBatchRequestStep batchRequestStep) {
5659
if (batchRequestStepsHashMap.containsKey(batchRequestStep.getRequestId()) ||
5760
batchRequestStepsHashMap.size() >= MAX_NUMBER_OF_REQUESTS)
5861
return false;
@@ -66,7 +69,8 @@ public boolean addBatchRequestStep(final MSBatchRequestStep batchRequestStep) {
6669
* @param arrayOfDependsOnIds ids of steps this step depends on
6770
* @return the step id
6871
*/
69-
public String addBatchRequestStep(final Request request, final String... arrayOfDependsOnIds) {
72+
@Nonnull
73+
public String addBatchRequestStep(@Nonnull final Request request, @Nullable final String... arrayOfDependsOnIds) {
7074
String requestId;
7175
do {
7276
requestId = Integer.toString(ThreadLocalRandom.current().nextInt(1, Integer.MAX_VALUE));
@@ -83,7 +87,7 @@ public String addBatchRequestStep(final Request request, final String... arrayOf
8387
* @return true or false based on removal or no removal of batch request step
8488
* with given id
8589
*/
86-
public boolean removeBatchRequestStepWithId(final String requestId) {
90+
public boolean removeBatchRequestStepWithId(@Nonnull final String requestId) {
8791
boolean removed = false;
8892
if (batchRequestStepsHashMap.containsKey(requestId)) {
8993
batchRequestStepsHashMap.remove(requestId);
@@ -101,6 +105,7 @@ public boolean removeBatchRequestStepWithId(final String requestId) {
101105
/*
102106
* @return Batch request content's json as String
103107
*/
108+
@Nonnull
104109
public String getBatchRequestContent() {
105110
final JsonObject batchRequestContentMap = new JsonObject();
106111
final JsonArray batchContentArray = new JsonArray();

‎src/main/java/com/microsoft/graph/content/MSBatchRequestStep.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22

33
import java.util.List;
44

5+
import javax.annotation.Nullable;
6+
import javax.annotation.Nonnull;
7+
58
import okhttp3.Request;
69

710
public class MSBatchRequestStep {
811
private String requestId;
912
private Request request;
1013
private List<String> arrayOfDependsOnIds;
1114

12-
public MSBatchRequestStep(String requestId, Request request, List<String> arrayOfDependsOnIds) {
15+
public MSBatchRequestStep(@Nonnull final String requestId, @Nonnull final Request request, @Nullable final List<String> arrayOfDependsOnIds) {
1316
if(requestId == null)
1417
throw new IllegalArgumentException("Request Id cannot be null.");
1518
if(requestId.length() == 0)
@@ -22,14 +25,17 @@ public MSBatchRequestStep(String requestId, Request request, List<String> arrayO
2225
this.arrayOfDependsOnIds = arrayOfDependsOnIds;
2326
}
2427

28+
@Nonnull
2529
public String getRequestId() {
2630
return requestId;
2731
}
2832

33+
@Nonnull
2934
public Request getRequest() {
3035
return request;
3136
}
3237

38+
@Nullable
3339
public List<String> getArrayOfDependsOnIds(){
3440
return arrayOfDependsOnIds;
3541
}

‎src/main/java/com/microsoft/graph/content/MSBatchResponseContent.java‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import java.util.Iterator;
66
import java.util.Map;
77

8+
import javax.annotation.Nullable;
9+
import javax.annotation.Nonnull;
10+
811
import com.google.gson.JsonArray;
912
import com.google.gson.JsonElement;
1013
import com.google.gson.JsonObject;
@@ -28,7 +31,7 @@ public class MSBatchResponseContent {
2831
/*
2932
* @param batchResponse OkHttp batch response on execution of batch requests
3033
*/
31-
public MSBatchResponseContent(final Response batchResponse) {
34+
public MSBatchResponseContent(@Nullable final Response batchResponse) {
3235
this.batchResponse = batchResponse;
3336
update(batchResponse);
3437
}
@@ -40,7 +43,8 @@ public MSBatchResponseContent(final Response batchResponse) {
4043
*
4144
* @return OkHttp Response corresponding to requestId
4245
*/
43-
public Response getResponseById(final String requestId) {
46+
@Nullable
47+
public Response getResponseById(@Nonnull final String requestId) {
4448
if (batchResponseArray == null)
4549
return null;
4650

@@ -106,6 +110,7 @@ public Response getResponseById(final String requestId) {
106110
*
107111
* @return responses in Map of id and response
108112
*/
113+
@Nonnull
109114
public Map<String, Response> getResponses() {
110115
if (batchResponseArray == null)
111116
return null;
@@ -121,12 +126,13 @@ public Map<String, Response> getResponses() {
121126
*
122127
* @return iterator for responses
123128
*/
129+
@Nullable
124130
public Iterator<Map.Entry<String, Response>> getResponsesIterator() {
125131
final Map<String, Response> responsesMap = getResponses();
126132
return responsesMap != null ? responsesMap.entrySet().iterator() : null;
127133
}
128134

129-
public void update(final Response batchResponse) {
135+
public void update(@Nonnull final Response batchResponse) {
130136
if (batchResponse == null)
131137
throw new IllegalArgumentException("Batch Response cannot be null");
132138

@@ -166,6 +172,7 @@ public void update(final Response batchResponse) {
166172
/*
167173
* @return nextLink of batch response
168174
*/
175+
@Nullable
169176
public String nextLink() {
170177
return nextLink;
171178
}

‎src/main/java/com/microsoft/graph/httpcore/AuthenticationHandler.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import java.io.IOException;
44

5+
import javax.annotation.Nullable;
6+
import javax.annotation.Nonnull;
7+
58
import com.microsoft.graph.httpcore.middlewareoption.MiddlewareType;
69
import com.microsoft.graph.httpcore.middlewareoption.TelemetryOptions;
710

@@ -15,12 +18,13 @@ public class AuthenticationHandler implements Interceptor {
1518

1619
private ICoreAuthenticationProvider authProvider;
1720

18-
public AuthenticationHandler(ICoreAuthenticationProvider authProvider) {
21+
public AuthenticationHandler(@Nonnull final ICoreAuthenticationProvider authProvider) {
1922
this.authProvider = authProvider;
2023
}
2124

2225
@Override
23-
public Response intercept(Chain chain) throws IOException {
26+
@Nullable
27+
public Response intercept(@Nonnull final Chain chain) throws IOException {
2428
Request originalRequest = chain.request();
2529

2630
if(originalRequest.tag(TelemetryOptions.class) == null)

‎src/main/java/com/microsoft/graph/httpcore/ChaosHttpHandler.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import java.io.IOException;
44
import java.util.concurrent.ThreadLocalRandom;
55

6+
import javax.annotation.Nullable;
7+
import javax.annotation.Nonnull;
8+
69
import com.microsoft.graph.httpcore.middlewareoption.MiddlewareType;
710
import com.microsoft.graph.httpcore.middlewareoption.TelemetryOptions;
811

@@ -38,7 +41,8 @@ public class ChaosHttpHandler implements Interceptor {
3841
public static final int MSClientErrorCodeTooManyRequests = 429;
3942

4043
@Override
41-
public Response intercept(Chain chain) throws IOException {
44+
@Nullable
45+
public Response intercept(@Nonnull final Chain chain) throws IOException {
4246
Request request = chain.request();
4347

4448
if(request.tag(TelemetryOptions.class) == null)

‎src/main/java/com/microsoft/graph/httpcore/HttpClients.java‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import java.util.Arrays;
44

5+
import javax.annotation.Nullable;
6+
import javax.annotation.Nonnull;
7+
58
import okhttp3.Interceptor;
69
import okhttp3.OkHttpClient;
710
import okhttp3.Protocol;
@@ -32,7 +35,8 @@ public static Builder custom() {
3235
* @param auth Use IAuthenticationProvider instance provided while constructing http client
3336
* @return OkHttpClient build with authentication provider given, default redirect and default retry handlers
3437
*/
35-
public static OkHttpClient createDefault(ICoreAuthenticationProvider auth) {
38+
@Nonnull
39+
public static OkHttpClient createDefault(@Nonnull final ICoreAuthenticationProvider auth) {
3640
return custom()
3741
.addInterceptor(new AuthenticationHandler(auth))
3842
.addInterceptor(new RetryHandler())
@@ -46,7 +50,8 @@ public static OkHttpClient createDefault(ICoreAuthenticationProvider auth) {
4650
* @param interceptors Use interceptors provided while constructing http client
4751
* @return OkHttpClient build with interceptors provided
4852
*/
49-
public static OkHttpClient createFromInterceptors(Interceptor[] interceptors) {
53+
@Nonnull
54+
public static OkHttpClient createFromInterceptors(@Nullable final Interceptor[] interceptors) {
5055
OkHttpClient.Builder builder = custom();
5156
if(interceptors != null)
5257
for(Interceptor interceptor : interceptors) {

‎src/main/java/com/microsoft/graph/httpcore/ICoreAuthenticationProvider.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
import okhttp3.Request;
44

5+
import javax.annotation.Nonnull;
6+
57
public interface ICoreAuthenticationProvider {
68
/**
79
* Authenticates the request
810
*
911
* @param request the request to authenticate
1012
* @return Request with Authorization header added to it
1113
*/
12-
Request authenticateRequest(Request request);
14+
@Nonnull
15+
Request authenticateRequest(@Nonnull final Request request);
1316
}

‎src/main/java/com/microsoft/graph/httpcore/RedirectHandler.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
import java.io.IOException;
1010
import java.net.ProtocolException;
1111

12+
import javax.annotation.Nullable;
13+
import javax.annotation.Nonnull;
14+
1215
import com.microsoft.graph.httpcore.middlewareoption.MiddlewareType;
1316
import com.microsoft.graph.httpcore.middlewareoption.RedirectOptions;
1417
import com.microsoft.graph.httpcore.middlewareoption.TelemetryOptions;
@@ -34,7 +37,7 @@ public RedirectHandler() {
3437
/*
3538
* @param redirectOptions pass instance of redirect options to be used
3639
*/
37-
public RedirectHandler(RedirectOptions redirectOptions) {
40+
public RedirectHandler(@Nullable final RedirectOptions redirectOptions) {
3841
this.mRedirectOptions = redirectOptions;
3942
if(redirectOptions == null) {
4043
this.mRedirectOptions = new RedirectOptions();
@@ -105,7 +108,8 @@ Request getRedirect(
105108

106109
// Intercept request and response made to network
107110
@Override
108-
public Response intercept(Chain chain) throws IOException {
111+
@Nullable
112+
public Response intercept(@Nonnull final Chain chain) throws IOException {
109113
Request request = chain.request();
110114

111115
if(request.tag(TelemetryOptions.class) == null)

‎src/main/java/com/microsoft/graph/httpcore/RetryHandler.java‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import java.io.IOException;
44

5+
import javax.annotation.Nullable;
6+
import javax.annotation.Nonnull;
7+
58
import com.microsoft.graph.httpcore.middlewareoption.IShouldRetry;
69
import com.microsoft.graph.httpcore.middlewareoption.MiddlewareType;
710
import com.microsoft.graph.httpcore.middlewareoption.RetryOptions;
@@ -36,7 +39,7 @@ public class RetryHandler implements Interceptor{
3639
/*
3740
* @retryOption Create Retry handler using retry option
3841
*/
39-
public RetryHandler(RetryOptions retryOption) {
42+
public RetryHandler(@Nullable final RetryOptions retryOption) {
4043
this.mRetryOption = retryOption;
4144
if(this.mRetryOption == null) {
4245
this.mRetryOption = new RetryOptions();
@@ -130,7 +133,8 @@ boolean isBuffered(Response response, Request request) {
130133
}
131134

132135
@Override
133-
public Response intercept(Chain chain) throws IOException {
136+
@Nullable
137+
public Response intercept(@Nonnull final Chain chain) throws IOException {
134138
Request request = chain.request();
135139

136140
if(request.tag(TelemetryOptions.class) == null)

‎src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import java.io.IOException;
44

5+
import javax.annotation.Nullable;
6+
import javax.annotation.Nonnull;
7+
58
import com.microsoft.graph.httpcore.middlewareoption.TelemetryOptions;
69

710
import okhttp3.Interceptor;
@@ -17,7 +20,8 @@ public class TelemetryHandler implements Interceptor{
1720
public static final String CLIENT_REQUEST_ID = "client-request-id";
1821

1922
@Override
20-
public Response intercept(Chain chain) throws IOException {
23+
@Nullable
24+
public Response intercept(@Nonnull final Chain chain) throws IOException {
2125
Request request = chain.request();
2226
Request.Builder telemetryAddedBuilder = request.newBuilder();
2327

0 commit comments

Comments
 (0)