Skip to content

Commit 11d0992

Browse files
committed
Use compatibility.isBlank for empty string check
1 parent 9959a96 commit 11d0992

File tree

11 files changed

+29
-32
lines changed

11 files changed

+29
-32
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.microsoft.graph.content;
22

3-
import com.google.common.base.Strings;
43
import com.google.gson.*;
54
import com.google.gson.stream.JsonWriter;
65
import com.microsoft.graph.CoreConstants;
76
import com.microsoft.graph.exceptions.ClientException;
87
import com.microsoft.graph.exceptions.ErrorConstants;
98
import com.microsoft.graph.models.BatchRequestStep;
109
import com.microsoft.graph.requests.IBaseClient;
10+
import com.microsoft.kiota.Compatibility;
1111
import com.microsoft.kiota.RequestAdapter;
1212
import com.microsoft.kiota.RequestInformation;
1313

@@ -126,7 +126,7 @@ public String addBatchRequestStep(@Nonnull RequestInformation requestInformation
126126
* @return True if the request was removed, false otherwise.
127127
*/
128128
public boolean removeBatchRequestStepWithId(@Nonnull String requestId) {
129-
if(Strings.isNullOrEmpty(requestId)) {
129+
if(Compatibility.isBlank(requestId)) {
130130
throw new IllegalArgumentException("requestId cannot be null or empty.");
131131
}
132132
boolean isRemoved = false;
@@ -251,7 +251,7 @@ private boolean containsCorrespondingRequestId(List<String> dependsOn) {
251251
private String getRelativeUrl(HttpUrl url) {
252252
String query = url.encodedQuery(); //Query must be encoded in order for batch requests to work.
253253
String path = url.encodedPath().substring(5);
254-
if(Strings.isNullOrEmpty(query)) {
254+
if(Compatibility.isBlank(query)) {
255255
return path;
256256
}
257257
return (path + "?" + query); // `v1.0/` and `beta/` are both 5 characters

src/main/java/com/microsoft/graph/exceptions/ClientException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public ClientException(@Nonnull String message, @Nonnull Throwable cause) {
1818
}
1919
/***
2020
* Constructor for a ClientException
21-
* @param message Th exception message.
21+
* @param message The exception message.
2222
*/
2323
public ClientException(@Nonnull String message) {
2424
super(message);

src/main/java/com/microsoft/graph/exceptions/ServiceException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.microsoft.graph.exceptions;
22

3-
import com.google.common.base.Strings;
43
import com.microsoft.kiota.ApiException;
4+
import com.microsoft.kiota.Compatibility;
55
import com.microsoft.kiota.serialization.AdditionalDataHolder;
66
import com.microsoft.kiota.serialization.Parsable;
77
import com.microsoft.kiota.serialization.ParseNode;
@@ -106,7 +106,7 @@ public void setRawResponseBody(@Nonnull String rawResponseBody) {
106106
* @return a boolean declaring whether the error code was found within the error stack.
107107
*/
108108
public boolean isMatch(@Nonnull String errorCode) {
109-
if(Strings.isNullOrEmpty(errorCode)) {
109+
if(Compatibility.isBlank(errorCode)) {
110110
throw new IllegalArgumentException("Parameter 'errorCode 'cannot be null or empty");
111111
}
112112
return (this.rawResponseBody.toLowerCase(Locale.ROOT).contains(errorCode.toLowerCase(Locale.ROOT)))

src/main/java/com/microsoft/graph/models/BatchRequestStep.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.microsoft.graph.models;
22

3-
import com.google.common.base.Strings;
43
import com.microsoft.graph.CoreConstants;
54
import com.microsoft.graph.exceptions.ErrorConstants;
5+
import com.microsoft.kiota.Compatibility;
66
import com.microsoft.kiota.http.middleware.UrlReplaceHandler;
77
import okhttp3.Request;
88

@@ -24,7 +24,7 @@ public class BatchRequestStep {
2424
*/
2525
public BatchRequestStep(@Nonnull String requestId, @Nonnull Request request) {
2626
Objects.requireNonNull(request, ErrorConstants.Messages.NULL_PARAMETER + "request");
27-
if(Strings.isNullOrEmpty(requestId)) {
27+
if(Compatibility.isBlank(requestId)) {
2828
throw new IllegalArgumentException("requestId cannot be null or empty.");
2929
}
3030
this.requestId = requestId;
@@ -79,7 +79,7 @@ public void setDependsOn(@Nonnull List<String> dependsOn) {
7979
* @param id The id of the request to add to the dependsOn list.
8080
*/
8181
public void addDependsOnId(@Nonnull String id) {
82-
if(Strings.isNullOrEmpty(id)) {
82+
if(Compatibility.isBlank(id)) {
8383
throw new IllegalArgumentException("id cannot be null or empty");
8484
}
8585
if(dependsOn == null) {

src/main/java/com/microsoft/graph/models/UploadSession.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.microsoft.graph.models;
22

3-
import com.google.common.base.Strings;
43
import com.microsoft.graph.exceptions.ErrorConstants;
4+
import com.microsoft.kiota.Compatibility;
55
import com.microsoft.kiota.serialization.ParseNode;
66
import com.microsoft.kiota.serialization.SerializationWriter;
77

@@ -47,7 +47,7 @@ public String getUploadUrl() {
4747
* @param uploadUrl The upload url for the session.
4848
*/
4949
public void setUploadUrl(@Nonnull final String uploadUrl) {
50-
if(Strings.isNullOrEmpty(uploadUrl))
50+
if(Compatibility.isBlank(uploadUrl))
5151
throw new IllegalArgumentException("uploadUrl cannot be null or empty");
5252
this.uploadUrl = uploadUrl;
5353
}

src/main/java/com/microsoft/graph/requests/BaseGraphRequestAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.microsoft.graph.requests;
22

3-
import com.google.common.base.Strings;
43
import com.microsoft.graph.requests.options.GraphClientOption;
4+
import com.microsoft.kiota.Compatibility;
55
import com.microsoft.kiota.authentication.AuthenticationProvider;
66
import com.microsoft.kiota.http.OkHttpRequestAdapter;
77
import com.microsoft.kiota.serialization.ParseNodeFactory;
@@ -64,7 +64,7 @@ private static final EnumMap<Clouds, String> getCloudList() {
6464
@SuppressWarnings("LambdaLast")
6565
public BaseGraphRequestAdapter(@Nonnull final AuthenticationProvider authenticationProvider, @Nullable final ParseNodeFactory parseNodeFactory, @Nullable final SerializationWriterFactory serializationWriterFactory, @Nullable final OkHttpClient client, @Nullable final GraphClientOption graphClientOption, @Nullable String baseUrl) {
6666
super(authenticationProvider, parseNodeFactory, serializationWriterFactory, client != null ? client : GraphClientFactory.create(graphClientOption).build());
67-
if (!Strings.isNullOrEmpty(baseUrl)) {
67+
if (!Compatibility.isBlank(baseUrl)) {
6868
setBaseUrl(baseUrl);
6969
} else {
7070
setBaseUrl(determineBaseAddress(null, null));

src/main/java/com/microsoft/graph/requests/options/GraphClientOption.java

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

33
import java.util.UUID;
44

5+
import com.microsoft.kiota.Compatibility;
56
import jakarta.annotation.Nonnull;
67
import jakarta.annotation.Nullable;
78

8-
import com.google.common.base.Strings;
99
import com.microsoft.graph.CoreConstants;
1010
import com.microsoft.graph.requests.FeatureTracker;
1111
import com.microsoft.kiota.RequestOption;
@@ -35,7 +35,7 @@ public GraphClientOption() {
3535
* @param clientRequestId the client request id to set, preferably the string representation of a GUID
3636
*/
3737
public void setClientRequestId(@Nonnull final String clientRequestId) {
38-
if(Strings.isNullOrEmpty(clientRequestId)) {
38+
if(Compatibility.isBlank(clientRequestId)) {
3939
throw new IllegalArgumentException("clientRequestId cannot be null or empty");
4040
}
4141
this.clientRequestId = clientRequestId;
@@ -56,7 +56,7 @@ public String getClientRequestId() {
5656
* @param clientLibraryVersion client library version specified by user.
5757
*/
5858
public void setClientLibraryVersion(@Nonnull final String clientLibraryVersion) {
59-
if(Strings.isNullOrEmpty(clientLibraryVersion))
59+
if(Compatibility.isBlank(clientLibraryVersion))
6060
{
6161
throw new IllegalArgumentException("clientLibraryVersion cannot be null or empty");
6262
}
@@ -76,7 +76,7 @@ public String getClientLibraryVersion() {
7676
* @param coreLibraryVersion core library version specified by user.
7777
*/
7878
public void setCoreLibraryVersion(@Nonnull final String coreLibraryVersion) {
79-
if(Strings.isNullOrEmpty(coreLibraryVersion))
79+
if(Compatibility.isBlank(coreLibraryVersion))
8080
{
8181
throw new IllegalArgumentException("coreLibraryVersion cannot be null or empty");
8282
}
@@ -96,7 +96,7 @@ public String getCoreLibraryVersion() {
9696
* @param graphServiceVersion the version of the Api endpoint we are targeting
9797
*/
9898
public void setGraphServiceTargetVersion(@Nonnull final String graphServiceVersion) {
99-
if(Strings.isNullOrEmpty(graphServiceVersion))
99+
if(Compatibility.isBlank(graphServiceVersion))
100100
{
101101
throw new IllegalArgumentException("graphServiceVersion cannot be null or empty");
102102
}

src/main/java/com/microsoft/graph/requests/upload/UploadSessionRequestBuilder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.microsoft.graph.requests.upload;
22

3-
import com.google.common.base.Strings;
43
import com.microsoft.graph.models.IUploadSession;
54
import com.microsoft.graph.models.UploadResult;
65
import com.microsoft.kiota.*;
@@ -33,7 +32,7 @@ public UploadSessionRequestBuilder(@Nonnull String sessionUrl,
3332
@Nonnull final ParsableFactory<T> factory) {
3433
this.responseHandler = new UploadResponseHandler();
3534
this.requestAdapter = Objects.requireNonNull(requestAdapter);
36-
if(Strings.isNullOrEmpty(sessionUrl))
35+
if(Compatibility.isBlank(sessionUrl))
3736
{
3837
throw new IllegalArgumentException("sessionUrl cannot be null or empty");
3938
}

src/main/java/com/microsoft/graph/requests/upload/UploadSliceRequestBuilder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.microsoft.graph.requests.upload;
22

3-
import com.google.common.base.Strings;
43
import com.microsoft.graph.models.UploadResult;
54
import com.microsoft.kiota.*;
65
import com.microsoft.kiota.serialization.Parsable;
@@ -42,7 +41,7 @@ public UploadSliceRequestBuilder(@Nonnull String sessionUrl,
4241
long rangeEnd,
4342
long totalSessionLength,
4443
@Nonnull ParsableFactory<T> factory) {
45-
if(Strings.isNullOrEmpty(sessionUrl))
44+
if(Compatibility.isBlank(sessionUrl))
4645
{
4746
throw new IllegalArgumentException("sessionUrl cannot be null or empty");
4847
}

src/main/java/com/microsoft/graph/tasks/PageIterator.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.microsoft.graph.tasks;
22

3-
import com.google.common.base.Strings;
43
import com.microsoft.graph.CoreConstants;
54
import com.microsoft.graph.exceptions.ServiceException;
65
import com.microsoft.graph.requests.IBaseClient;
6+
import com.microsoft.kiota.Compatibility;
77
import com.microsoft.kiota.HttpMethod;
88
import com.microsoft.kiota.RequestAdapter;
99
import com.microsoft.kiota.RequestInformation;
@@ -113,13 +113,12 @@ protected void setPageItemQueue(@Nonnull Queue<TEntity> pageItemQueue) {
113113
}
114114
/**
115115
* A builder class for building a PageIterator.
116-
* This Builder class should be used when the processPageItemCallback is synchronous.
117116
* @param <TEntity> The type of the entity returned in the collection. This type must implement {@link Parsable}
118117
* @param <TCollectionPage> The Microsoft Graph collection response type returned in the collection response. This type must implement {@link Parsable} and {@link AdditionalDataHolder}
119118
*/
120119
public static class Builder<TEntity extends Parsable, TCollectionPage extends Parsable & AdditionalDataHolder> implements PageIteratorBuilder<TEntity, TCollectionPage>{
121120
/**
122-
* Constructor for the Builder class of a PageIterator with a synchronous processPageItemCallback.
121+
* Constructor for the Builder class of a PageIterator.
123122
*/
124123
public Builder() {
125124
// Default constructor
@@ -226,14 +225,14 @@ private boolean intrapageIterate() throws ReflectiveOperationException {
226225
}
227226

228227
String extractedNextLink = extractNextLinkFromParsable(this.currentPage, null);
229-
if (!Strings.isNullOrEmpty(extractedNextLink)){
228+
if (!Compatibility.isBlank(extractedNextLink)){
230229
this.nextLink = extractedNextLink;
231230
this.deltaLink = "";
232231
return true;
233232
}
234233

235234
String extractedDeltaLink = extractNextLinkFromParsable(this.currentPage, CoreConstants.CollectionResponseMethods.GET_ODATA_DELTA_LINK);
236-
if (!Strings.isNullOrEmpty(extractedDeltaLink)){
235+
if (!Compatibility.isBlank(extractedDeltaLink)){
237236
this.deltaLink = extractedDeltaLink;
238237
this.state = PageIteratorState.DELTA;
239238
} else {
@@ -245,10 +244,10 @@ private boolean intrapageIterate() throws ReflectiveOperationException {
245244
private void interpageIterate() throws ReflectiveOperationException, ServiceException {
246245
this.state = PageIteratorState.INTERPAGE_ITERATION;
247246

248-
if(!Strings.isNullOrEmpty(nextLink) || !Strings.isNullOrEmpty(deltaLink)) {
247+
if(!Compatibility.isBlank(nextLink) || !Compatibility.isBlank(deltaLink)) {
249248
RequestInformation nextPageRequestInformation = new RequestInformation();
250249
nextPageRequestInformation.httpMethod = HttpMethod.GET;
251-
nextPageRequestInformation.urlTemplate = Strings.isNullOrEmpty(nextLink) ? deltaLink : nextLink;
250+
nextPageRequestInformation.urlTemplate = Compatibility.isBlank(nextLink) ? deltaLink : nextLink;
252251

253252
nextPageRequestInformation = requestConfigurator == null ? nextPageRequestInformation : requestConfigurator.apply(nextPageRequestInformation);
254253
this.currentPage = Objects.requireNonNull(this.requestAdapter.send(nextPageRequestInformation, this.collectionPageFactory, null));
@@ -257,7 +256,7 @@ private void interpageIterate() throws ReflectiveOperationException, ServiceExce
257256
this.pageItemQueue.addAll(pageItems);
258257
}
259258
}
260-
if(!Strings.isNullOrEmpty(nextLink) && this.nextLink.equals(extractNextLinkFromParsable(this.currentPage, null))) {
259+
if(!Compatibility.isBlank(nextLink) && this.nextLink.equals(extractNextLinkFromParsable(this.currentPage, null))) {
261260
throw new ServiceException("Detected a nextLink loop. NextLink value: " + this.nextLink);
262261
}
263262
}
@@ -314,7 +313,7 @@ private static <TCollectionPage extends Parsable & AdditionalDataHolder> String
314313
if(Arrays.stream(methods).anyMatch(m -> m.getName().equals(methodName))) {
315314
try {
316315
nextLink = (String) parsableCollection.getClass().getDeclaredMethod(methodName).invoke(parsableCollection);
317-
if(!Strings.isNullOrEmpty(nextLink)) {
316+
if(!Compatibility.isBlank(nextLink)) {
318317
return nextLink;
319318
}
320319
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {

0 commit comments

Comments
 (0)