Skip to content

Commit 0d33073

Browse files
committed
Enum Refactor Release Candidate
1 parent eaa1cc6 commit 0d33073

File tree

9 files changed

+54
-23
lines changed

9 files changed

+54
-23
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
## [3.0.10-RC] - 2023-11-22
15+
16+
### Changed
17+
18+
- Removed the usage of reflection for enum deserialization and reordered RequestAdapter method arguments. [Kiota-Java #840](https://github.com/microsoft/kiota-java/issues/840)
19+
1420
## [3.0.9] - 2023-11-14
1521

1622
### Changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ mavenGroupId = com.microsoft.graph
2525
mavenArtifactId = microsoft-graph-core
2626
mavenMajorVersion = 3
2727
mavenMinorVersion = 0
28-
mavenPatchVersion = 9
29-
mavenArtifactSuffix =
28+
mavenPatchVersion = 10
29+
mavenArtifactSuffix = RC
3030

3131
#These values are used to run functional tests
3232
#If you wish to run the functional tests, edit the gradle.properties

gradle/dependencies.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ dependencies {
1616
api 'com.squareup.okhttp3:okhttp:4.12.0'
1717
api 'com.azure:azure-core:1.45.0'
1818

19-
api 'com.microsoft.kiota:microsoft-kiota-abstractions:0.9.2'
20-
implementation 'com.microsoft.kiota:microsoft-kiota-authentication-azure:0.9.2'
21-
implementation 'com.microsoft.kiota:microsoft-kiota-http-okHttp:0.9.2'
22-
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-json:0.9.2'
23-
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-text:0.9.2'
24-
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-text:0.9.2'
25-
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-form:0.9.2'
19+
api 'com.microsoft.kiota:microsoft-kiota-abstractions:0.10.0'
20+
implementation 'com.microsoft.kiota:microsoft-kiota-authentication-azure:0.10.0'
21+
implementation 'com.microsoft.kiota:microsoft-kiota-http-okHttp:0.10.0'
22+
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-json:0.10.0'
23+
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-text:0.10.0'
24+
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-text:0.10.0'
25+
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-form:0.10.0'
2626
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public BatchResponseContent post(@Nonnull BatchRequestContent requestContent, @N
4949
RequestInformation requestInfo = toPostRequestInformation(requestContent);
5050
NativeResponseHandler nativeResponseHandler = new NativeResponseHandler();
5151
requestInfo.setResponseHandler(nativeResponseHandler);
52-
requestAdapter.sendPrimitive(requestInfo, InputStream.class, errorMappings == null ? null : new HashMap<>(errorMappings));
52+
requestAdapter.sendPrimitive(requestInfo, errorMappings == null ? null : new HashMap<>(errorMappings) ,InputStream.class);
5353
return new BatchResponseContent((Response) nativeResponseHandler.getValue(), errorMappings);
5454
}
5555
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public IUploadSession get() {
4848
RequestInformation requestInformation = toGetRequestInformation();
4949
NativeResponseHandler nativeResponseHandler = new NativeResponseHandler();
5050
requestInformation.setResponseHandler(nativeResponseHandler);
51-
requestAdapter.sendPrimitive(requestInformation, InputStream.class, null);
51+
requestAdapter.sendPrimitive(requestInformation, null, InputStream.class);
5252
UploadResult<T> result = responseHandler.handleResponse((Response) nativeResponseHandler.getValue(), factory);
5353
return result.uploadSession;
5454
}
@@ -63,7 +63,7 @@ private RequestInformation toGetRequestInformation() {
6363
*/
6464
public void delete() {
6565
RequestInformation requestInfo = this.toDeleteRequestInformation();
66-
this.requestAdapter.sendPrimitive(requestInfo, Void.class, null);
66+
this.requestAdapter.sendPrimitive(requestInfo, null, Void.class);
6767
}
6868
private RequestInformation toDeleteRequestInformation() {
6969
RequestInformation requestInformation = new RequestInformation();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public UploadResult<T> put(@Nonnull InputStream stream) {
6565
RequestInformation requestInformation = this.toPutRequestInformation(stream);
6666
NativeResponseHandler nativeResponseHandler = new NativeResponseHandler();
6767
requestInformation.setResponseHandler(nativeResponseHandler);
68-
requestAdapter.sendPrimitive(requestInformation, InputStream.class, null);
68+
requestAdapter.sendPrimitive(requestInformation,null, InputStream.class);
6969
return responseHandler.handleResponse((Response) nativeResponseHandler.getValue(), factory);
7070
}
7171
private RequestInformation toPutRequestInformation(InputStream stream) {

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private boolean intrapageIterate() throws ReflectiveOperationException {
237237
this.nextLink = "";
238238
return false;
239239
}
240-
private void interpageIterate() throws ReflectiveOperationException, ApiException {
240+
private void interpageIterate() throws ReflectiveOperationException {
241241
this.state = PageIteratorState.INTERPAGE_ITERATION;
242242

243243
if(!Compatibility.isBlank(nextLink) || !Compatibility.isBlank(deltaLink)) {
@@ -246,7 +246,7 @@ private void interpageIterate() throws ReflectiveOperationException, ApiExceptio
246246
nextPageRequestInformation.urlTemplate = Compatibility.isBlank(nextLink) ? deltaLink : nextLink;
247247

248248
nextPageRequestInformation = requestConfigurator == null ? nextPageRequestInformation : requestConfigurator.apply(nextPageRequestInformation);
249-
this.currentPage = Objects.requireNonNull(this.requestAdapter.send(nextPageRequestInformation, this.collectionPageFactory, null));
249+
this.currentPage = Objects.requireNonNull(this.requestAdapter.send(nextPageRequestInformation, null, this.collectionPageFactory));
250250
List<TEntity> pageItems = extractEntityListFromParsable(this.currentPage);
251251
if(!pageItems.isEmpty()) {
252252
this.pageItemQueue.addAll(pageItems);
@@ -263,7 +263,6 @@ private void interpageIterate() throws ReflectiveOperationException, ApiExceptio
263263
* @throws ApiException if the request was unable to complete for any reason.
264264
* @throws ReflectiveOperationException if the entity or collection page could not be instantiated or if they are of invalid types.
265265
*/
266-
@Nonnull
267266
public void iterate() throws ApiException, ReflectiveOperationException {
268267
if(this.state == PageIteratorState.DELTA) {
269268
interpageIterate();
@@ -280,7 +279,6 @@ public void iterate() throws ApiException, ReflectiveOperationException {
280279
* @throws ApiException if the request was unable to complete for any reason.
281280
* @throws ReflectiveOperationException if the entity or collection page could not be instantiated or if they are of invalid types.
282281
*/
283-
@Nonnull
284282
public void resume() throws ApiException, ReflectiveOperationException {
285283
iterate();
286284
}
Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
package com.microsoft.graph.testModels;
22

3-
public enum TestBodyType {
4-
Text,
5-
Html
3+
import com.microsoft.kiota.serialization.ValuedEnum;
4+
import jakarta.annotation.Nonnull;
5+
import jakarta.annotation.Nullable;
6+
7+
import java.util.Objects;
8+
9+
public enum TestBodyType implements ValuedEnum {
10+
Text("Text"),
11+
Html("Html");
12+
public final String value;
13+
14+
TestBodyType(@Nonnull final String value) {
15+
this.value = value;
16+
}
17+
18+
@Nonnull
19+
@Override
20+
public String getValue() {
21+
return this.value;
22+
}
23+
24+
@Nullable public static TestBodyType forValue(@Nullable final String searchValue) {
25+
Objects.requireNonNull(searchValue);
26+
switch(searchValue) {
27+
case "Text": return Text;
28+
case "Html": return Html;
29+
default: return null;
30+
}
31+
}
32+
633
}

src/test/java/com/microsoft/graph/testModels/TestItemBody.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public void setODataType(String oDataType) {
5353

5454
public HashMap<String, Consumer<ParseNode>> getFieldDeserializers() {
5555
return new HashMap<String, Consumer<ParseNode>>() {{
56-
put("@odata.type", (n) -> { oDataType = n.getStringValue(); });
57-
put("contentType", (n) -> { contentType = n.getEnumValue(TestBodyType.class); });
58-
put("content", (n) -> { content = n.getStringValue(); });
56+
put("@odata.type", (n) -> { setODataType(n.getStringValue()); });
57+
put("contentType", (n) -> { setContentType(n.getEnumValue(TestBodyType::forValue)); });
58+
put("content", (n) -> { setContent(n.getStringValue()); });
5959
}};
6060
}
6161

0 commit comments

Comments
 (0)