Skip to content

Commit 2cc9445

Browse files
committed
- fixes linting issues
1 parent 92cb5ec commit 2cc9445

5 files changed

Lines changed: 19 additions & 4 deletions

File tree

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.HashMap;
2828
import java.util.HashSet;
2929
import java.util.List;
30+
import java.util.Locale;
3031
import java.util.Objects;
3132
import java.util.concurrent.ThreadLocalRandom;
3233
import java.util.regex.Matcher;
@@ -46,6 +47,7 @@
4647
public class BatchRequestContent {
4748
/** Steps part of the batch request */
4849
@Expose
50+
@Nullable
4951
@SerializedName("requests")
5052
public List<BatchRequestStep<?>> requests;
5153

@@ -90,6 +92,7 @@ public <T> String addBatchRequestStep(@Nonnull final IHttpRequest request, @Nonn
9092
* @param dependsOnRequestsIds the ids of steps this request depends on
9193
* @return the id of the step that was just added to the batch
9294
*/
95+
@Nonnull
9396
public <T> String addBatchRequestStep(@Nonnull final IHttpRequest request, @Nonnull final HttpMethod httpMethod, @Nullable final T serializableBody, @Nullable final String ...dependsOnRequestsIds) {
9497
Objects.requireNonNull(request, "request parameter cannot be null");
9598
Objects.requireNonNull(httpMethod, "httpMethod parameter cannot be null");
@@ -106,15 +109,15 @@ public <T> String addBatchRequestStep(@Nonnull final IHttpRequest request, @Nonn
106109
final BatchRequestStep<T> step = new BatchRequestStep<T>() {{
107110
url = protocolAndHostReplacementMatcher.replaceAll("");
108111
body = serializableBody;
109-
method = httpMethod.toString().toUpperCase();
112+
method = httpMethod.toString().toUpperCase(Locale.getDefault());
110113
dependsOn = dependsOnRequestsIds != null && dependsOnRequestsIds.length > 0 ? new HashSet<String>(Arrays.asList(dependsOnRequestsIds)) : null;
111114
id = getNextRequestId();
112115
}};
113116

114117
if(!request.getHeaders().isEmpty()) {
115118
step.headers = new HashMap<>();
116119
for(final HeaderOption headerOption : request.getHeaders())
117-
step.headers.putIfAbsent(headerOption.getName().toLowerCase(), headerOption.getValue().toString());
120+
step.headers.putIfAbsent(headerOption.getName().toLowerCase(Locale.getDefault()), headerOption.getValue().toString());
118121
}
119122
if(step.body != null && step.body instanceof IJsonBackedObject &&
120123
(step.headers == null || !step.headers.containsKey(contentTypeHeaderKey))) {
@@ -163,8 +166,15 @@ public <T> BatchRequestStep<T> getStepById(@Nonnull final String stepId) {
163166
}
164167
return null;
165168
}
166-
private static final Pattern protocolAndHostReplacementPattern = Pattern.compile("(?i)^http[s]?:\\/\\/graph\\.microsoft\\.com\\/(?>v1\\.0|beta)\\/?"); // (?i) case insensitive
167-
private String getNextRequestId() {
169+
/** pattern to replace the protocol and host part of the request if specified */
170+
@Nonnull
171+
protected static final Pattern protocolAndHostReplacementPattern = Pattern.compile("(?i)^http[s]?:\\/\\/graph\\.microsoft\\.com\\/(?>v1\\.0|beta)\\/?"); // (?i) case insensitive
172+
/**
173+
* Generates a randomly available request id
174+
* @return a random request id
175+
*/
176+
@Nonnull
177+
protected String getNextRequestId() {
168178
String requestId;
169179
do {
170180
requestId = Integer.toString(ThreadLocalRandom.current().nextInt(1, Integer.MAX_VALUE));

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ public class BatchRequestStep<T> extends BatchStep<T> {
3737
@SerializedName("url")
3838
public String url;
3939
/** The HTTP method to use to execute the request */
40+
@Nullable
4041
@Expose
4142
@SerializedName("method")
4243
public String method;
4344
/** The IDs of the steps this step depends on before being executed */
45+
@Nullable
4446
@Expose
4547
@SerializedName("dependsOn")
4648
public HashSet<String> dependsOn;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
/** Respresents the result of a JSON batch request */
3636
public class BatchResponseContent {
3737
/** Responses to the steps from the request */
38+
@Nullable
3839
@Expose
3940
@SerializedName("responses")
4041
public List<BatchResponseStep<JsonElement>> responses;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class BatchResponseStep<T> extends BatchStep<T> {
4242
@SerializedName("status")
4343
public int status;
4444
/** Serializer to use for response deserialization */
45+
@Nullable
4546
protected ISerializer serializer;
4647

4748
/**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public abstract class BatchStep<T> {
4242
@SerializedName("headers")
4343
public HashMap<String, String> headers;
4444
/** The body of request/response for the step */
45+
@Nullable
4546
@Expose
4647
@SerializedName("body")
4748
public T body;

0 commit comments

Comments
 (0)