Skip to content

Commit f231e5a

Browse files
authored
Merge pull request #310 from valenpo/dev
update 300, fix 309
2 parents e07b0b2 + d6a2aa0 commit f231e5a

27 files changed

+182
-303
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +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;
9+
import java.util.Collections;
810
import java.util.List;
911
import java.util.Objects;
1012
import java.util.concurrent.CompletableFuture;
1113

12-
import javax.annotation.Nonnull;
13-
1414
/**
1515
* An implementation of the Authentication Provider with Azure-identity
1616
*/
@@ -27,7 +27,7 @@ public class TokenCredentialAuthProvider extends BaseAuthenticationProvider {
2727
* @param tokenCredential Credential object inheriting the TokenCredential interface used to instantiate the Auth Provider
2828
*/
2929
public TokenCredentialAuthProvider(@Nonnull final TokenCredential tokenCredential) {
30-
this(Arrays.asList(DEFAULT_GRAPH_SCOPE), tokenCredential);
30+
this(Collections.singletonList(DEFAULT_GRAPH_SCOPE), tokenCredential);
3131
}
3232

3333
/**
@@ -56,7 +56,7 @@ public CompletableFuture<String> getAuthorizationTokenAsync(@Nonnull final URL r
5656
return this.tokenCredential
5757
.getToken(this.context)
5858
.toFuture()
59-
.thenApply(resp -> resp.getToken());
59+
.thenApply(AccessToken::getToken);
6060
else
6161
return CompletableFuture.completedFuture((String)null);
6262
}

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: 3 additions & 3 deletions
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
/**
@@ -125,7 +125,7 @@ public static String createContentHeaderValue(@Nonnull final String contentValue
125125

126126
if(contentDispParameter != null) {
127127
for(Map.Entry<String,String> entry : contentDispParameter.entrySet())
128-
builder.append(";" + entry.getKey() + "=\"" + entry.getValue() + "\"");
128+
builder.append(";").append(entry.getKey()).append("=\"").append(entry.getValue()).append("\"");
129129
}
130130
return builder.toString();
131131
}
@@ -140,7 +140,7 @@ private String createPartHeader(Map<String, String> headers) {
140140

141141
if(headers != null) {
142142
for(Map.Entry<String,String> entry : headers.entrySet())
143-
builder.append(entry.getKey() +": "+entry.getValue() + RETURN);
143+
builder.append(entry.getKey()).append(": ").append(entry.getValue()).append(RETURN);
144144
builder.append(RETURN);
145145
} else
146146
builder.append(defaultPartContent);

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: 3 additions & 3 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;
@@ -228,7 +228,7 @@ private String addFunctionParameters() {
228228
requestUrl.append("=");
229229
if (option.getValue() != null) {
230230
if (option.getValue() instanceof String) {
231-
requestUrl.append("'" + option.getValue() + "'");
231+
requestUrl.append("'").append(option.getValue()).append("'");
232232
} else {
233233
requestUrl.append(option.getValue());
234234
}

0 commit comments

Comments
 (0)