Skip to content

Commit a202298

Browse files
author
Valentin Popov
committed
java 8 code migration style
1 parent ffb2962 commit a202298

21 files changed

+123
-280
lines changed

src/main/java/com/microsoft/graph/authentication/TokenCredentialAuthProvider.java

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

3+
import com.azure.core.credential.AccessToken;
34
import com.azure.core.credential.TokenCredential;
45
import com.azure.core.credential.TokenRequestContext;
56

7+
import javax.annotation.Nonnull;
68
import java.net.URL;
7-
import java.util.Arrays;
89
import java.util.Collections;
910
import java.util.List;
1011
import java.util.Objects;
1112
import java.util.concurrent.CompletableFuture;
1213

13-
import javax.annotation.Nonnull;
14-
1514
/**
1615
* An implementation of the Authentication Provider with Azure-identity
1716
*/
@@ -57,7 +56,7 @@ public CompletableFuture<String> getAuthorizationTokenAsync(@Nonnull final URL r
5756
return this.tokenCredential
5857
.getToken(this.context)
5958
.toFuture()
60-
.thenApply(resp -> resp.getToken());
59+
.thenApply(AccessToken::getToken);
6160
else
6261
return CompletableFuture.completedFuture((String)null);
6362
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public <T> String addBatchRequestStep(@Nonnull final IHttpRequest request, @Nonn
110110
url = protocolAndHostReplacementMatcher.replaceAll("");
111111
body = serializableBody;
112112
method = httpMethod.toString().toUpperCase(Locale.getDefault());
113-
dependsOn = dependsOnRequestsIds != null && dependsOnRequestsIds.length > 0 ? new HashSet<String>(Arrays.asList(dependsOnRequestsIds)) : null;
113+
dependsOn = dependsOnRequestsIds != null && dependsOnRequestsIds.length > 0 ? new HashSet<>(Arrays.asList(dependsOnRequestsIds)) : null;
114114
id = getNextRequestId();
115115
}};
116116

@@ -141,7 +141,7 @@ public void removeBatchRequestStepWithId(@Nonnull final String ...stepIds) {
141141
requests.removeIf(x -> stepId.equals(x.id));
142142
for(final BatchRequestStep<?> step : requests) {
143143
if(step.dependsOn != null) {
144-
step.dependsOn.removeIf(x -> stepId.equals(x));
144+
step.dependsOn.removeIf(stepId::equals);
145145
if(step.dependsOn.isEmpty())
146146
step.dependsOn = null; // so we don't send dependsOn: [] over the wire
147147
}

src/main/java/com/microsoft/graph/core/CustomRequestBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ public CustomRequest<T> buildRequest(@Nullable final com.microsoft.graph.options
5151
*/
5252
@Nonnull
5353
public CustomRequest<T> buildRequest(@Nullable final List<? extends Option> requestOptions) {
54-
return new CustomRequest<T>(getRequestUrl(), getClient(), requestOptions, responseType);
54+
return new CustomRequest<>(getRequestUrl(), getClient(), requestOptions, responseType);
5555
}
5656
}

src/main/java/com/microsoft/graph/core/IBaseClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public interface IBaseClient<nativeRequestType> {
100100
* @return a request builder to execute a batch.
101101
*/
102102
@Nonnull
103-
public BatchRequestBuilder batch();
103+
BatchRequestBuilder batch();
104104

105105
/**
106106
* Gets the service SDK version if the service SDK is in use, null otherwise

src/main/java/com/microsoft/graph/core/Multipart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class Multipart {
3535
*/
3636
public Multipart() {
3737
out = new ByteArrayOutputStream();
38-
boundary = "part_" + new BigInteger(130, new SecureRandom()).toString();
38+
boundary = "part_" + new BigInteger(130, new SecureRandom());
3939
}
4040

4141
/**

src/main/java/com/microsoft/graph/http/BaseActionCollectionRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public java.util.concurrent.CompletableFuture<T3> postAsync() {
8181
.sendAsync(this,
8282
responseCollectionClass,
8383
bodyToSend)
84-
.thenApply(r -> buildFromResponse(r));
84+
.thenApply(this::buildFromResponse);
8585
}
8686
/**
8787
* Invokes the method and returns the resulting collection of objects

src/main/java/com/microsoft/graph/http/BaseCollectionPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public BaseCollectionPage(@Nonnull final ICollectionResponse<T> response, @Nulla
7272
public BaseCollectionPage(@Nonnull final List<T> pageContents, @Nullable final T2 nextRequestBuilder) {
7373
// CollectionPages are never directly modifiable, either 'update'/'delete' the specific child or 'add' the new
7474
// object to the 'children' of the collection.
75-
this.pageContents = Collections.unmodifiableList(pageContents == null ? new ArrayList<T>() : pageContents);
75+
this.pageContents = Collections.unmodifiableList(pageContents == null ? new ArrayList<>() : pageContents);
7676
requestBuilder = nextRequestBuilder;
7777
}
7878

src/main/java/com/microsoft/graph/http/BaseEntityCollectionRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public BaseEntityCollectionRequest(@Nonnull final String requestUrl,
6666
*/
6767
@Nonnull
6868
public java.util.concurrent.CompletableFuture<T3> getAsync() {
69-
return sendAsync().thenApply(r -> buildFromResponse(r));
69+
return sendAsync().thenApply(this::buildFromResponse);
7070
}
7171
/**
7272
* Gets the collection of items

src/main/java/com/microsoft/graph/http/BaseFunctionCollectionRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public BaseFunctionCollectionRequest(@Nonnull final String requestUrl,
6666
*/
6767
@Nonnull
6868
public java.util.concurrent.CompletableFuture<T3> getAsync() {
69-
return sendAsync().thenApply(r -> buildFromResponse(r));
69+
return sendAsync().thenApply(this::buildFromResponse);
7070
}
7171

7272
/**

src/main/java/com/microsoft/graph/http/BaseRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ public URL getRequestUrl() {
193193
return new URL(uriBuilder.build().toString());
194194
} catch (final MalformedURLException e) {
195195
if (this instanceof CustomRequest) {
196-
this.getClient().getLogger().logError("Invalid custom URL: " + uriBuilder.toString(), e);
196+
this.getClient().getLogger().logError("Invalid custom URL: " + uriBuilder, e);
197197
} else {
198-
throw new ClientException("Invalid URL: " + uriBuilder.toString(), e);
198+
throw new ClientException("Invalid URL: " + uriBuilder, e);
199199
}
200200
}
201201
return null;

0 commit comments

Comments
 (0)