diff --git a/components/abstractions/src/main/java/com/microsoft/kiota/serialization/KiotaJsonSerialization.java b/components/abstractions/src/main/java/com/microsoft/kiota/serialization/KiotaJsonSerialization.java index ddf229f88..1309d814d 100644 --- a/components/abstractions/src/main/java/com/microsoft/kiota/serialization/KiotaJsonSerialization.java +++ b/components/abstractions/src/main/java/com/microsoft/kiota/serialization/KiotaJsonSerialization.java @@ -35,9 +35,9 @@ private KiotaJsonSerialization() {} * @throws IOException when the stream cannot be closed or read. */ @Nonnull public static InputStream serializeAsStream( - @Nonnull final T value, final boolean serializeOnlyChangedValues) throws IOException { + final boolean serializeOnlyChangedValues, @Nonnull final T value) throws IOException { return KiotaSerialization.serializeAsStream( - CONTENT_TYPE, value, serializeOnlyChangedValues); + CONTENT_TYPE, serializeOnlyChangedValues, value); } /** @@ -61,9 +61,9 @@ private KiotaJsonSerialization() {} * @throws IOException when the stream cannot be closed or read. */ @Nonnull public static String serializeAsString( - @Nonnull final T value, final boolean serializeOnlyChangedValues) throws IOException { + final boolean serializeOnlyChangedValues, @Nonnull final T value) throws IOException { return KiotaSerialization.serializeAsString( - CONTENT_TYPE, value, serializeOnlyChangedValues); + CONTENT_TYPE, serializeOnlyChangedValues, value); } /** @@ -87,10 +87,10 @@ private KiotaJsonSerialization() {} * @throws IOException when the stream cannot be closed or read. */ @Nonnull public static InputStream serializeAsStream( - @Nonnull final Iterable values, final boolean serializeOnlyChangedValues) + final boolean serializeOnlyChangedValues, @Nonnull final Iterable values) throws IOException { return KiotaSerialization.serializeAsStream( - CONTENT_TYPE, values, serializeOnlyChangedValues); + CONTENT_TYPE, serializeOnlyChangedValues, values); } /** @@ -114,10 +114,10 @@ private KiotaJsonSerialization() {} * @throws IOException when the stream cannot be closed or read. */ @Nonnull public static String serializeAsString( - @Nonnull final Iterable values, final boolean serializeOnlyChangedValues) + final boolean serializeOnlyChangedValues, @Nonnull final Iterable values) throws IOException { return KiotaSerialization.serializeAsString( - CONTENT_TYPE, values, serializeOnlyChangedValues); + CONTENT_TYPE, serializeOnlyChangedValues, values); } /** diff --git a/components/abstractions/src/main/java/com/microsoft/kiota/serialization/KiotaSerialization.java b/components/abstractions/src/main/java/com/microsoft/kiota/serialization/KiotaSerialization.java index a9c0a9e0e..11bb9ec90 100644 --- a/components/abstractions/src/main/java/com/microsoft/kiota/serialization/KiotaSerialization.java +++ b/components/abstractions/src/main/java/com/microsoft/kiota/serialization/KiotaSerialization.java @@ -30,7 +30,7 @@ private KiotaSerialization() {} */ @Nonnull public static InputStream serializeAsStream( @Nonnull final String contentType, @Nonnull final T value) throws IOException { - return serializeAsStream(contentType, value, DEFAULT_SERIALIZE_ONLY_CHANGED_VALUES); + return serializeAsStream(contentType, DEFAULT_SERIALIZE_ONLY_CHANGED_VALUES, value); } /** @@ -44,8 +44,8 @@ private KiotaSerialization() {} */ @Nonnull public static InputStream serializeAsStream( @Nonnull final String contentType, - @Nonnull final T value, - final boolean serializeOnlyChangedValues) + final boolean serializeOnlyChangedValues, + @Nonnull final T value) throws IOException { Objects.requireNonNull(value); try (final SerializationWriter writer = @@ -66,7 +66,7 @@ private KiotaSerialization() {} @Nonnull public static String serializeAsString( @Nonnull final String contentType, @Nonnull final T value) throws IOException { Objects.requireNonNull(value); - return serializeAsString(contentType, value, DEFAULT_SERIALIZE_ONLY_CHANGED_VALUES); + return serializeAsString(contentType, DEFAULT_SERIALIZE_ONLY_CHANGED_VALUES, value); } /** @@ -80,12 +80,12 @@ private KiotaSerialization() {} */ @Nonnull public static String serializeAsString( @Nonnull final String contentType, - @Nonnull final T value, - final boolean serializeOnlyChangedValues) + final boolean serializeOnlyChangedValues, + @Nonnull final T value) throws IOException { Objects.requireNonNull(value); try (final InputStream stream = - serializeAsStream(contentType, value, serializeOnlyChangedValues)) { + serializeAsStream(contentType, serializeOnlyChangedValues, value)) { return new String(Compatibility.readAllBytes(stream), CHARSET_NAME); } } @@ -102,7 +102,7 @@ private KiotaSerialization() {} @Nonnull final String contentType, @Nonnull final Iterable values) throws IOException { Objects.requireNonNull(values); - return serializeAsStream(contentType, values, DEFAULT_SERIALIZE_ONLY_CHANGED_VALUES); + return serializeAsStream(contentType, DEFAULT_SERIALIZE_ONLY_CHANGED_VALUES, values); } /** @@ -116,8 +116,8 @@ private KiotaSerialization() {} */ @Nonnull public static InputStream serializeAsStream( @Nonnull final String contentType, - @Nonnull final Iterable values, - final boolean serializeOnlyChangedValues) + final boolean serializeOnlyChangedValues, + @Nonnull final Iterable values) throws IOException { Objects.requireNonNull(values); try (final SerializationWriter writer = @@ -139,7 +139,7 @@ private KiotaSerialization() {} @Nonnull final String contentType, @Nonnull final Iterable values) throws IOException { Objects.requireNonNull(values); - return serializeAsString(contentType, values, DEFAULT_SERIALIZE_ONLY_CHANGED_VALUES); + return serializeAsString(contentType, DEFAULT_SERIALIZE_ONLY_CHANGED_VALUES, values); } /** @@ -153,12 +153,12 @@ private KiotaSerialization() {} */ @Nonnull public static String serializeAsString( @Nonnull final String contentType, - @Nonnull final Iterable values, - final boolean serializeOnlyChangedValues) + final boolean serializeOnlyChangedValues, + @Nonnull final Iterable values) throws IOException { Objects.requireNonNull(values); try (final InputStream stream = - serializeAsStream(contentType, values, serializeOnlyChangedValues)) { + serializeAsStream(contentType, serializeOnlyChangedValues, values)) { return new String(Compatibility.readAllBytes(stream), CHARSET_NAME); } } diff --git a/components/abstractions/src/test/java/com/microsoft/kiota/serialization/SerializationHelpersTest.java b/components/abstractions/src/test/java/com/microsoft/kiota/serialization/SerializationHelpersTest.java index a43f5b191..1e2f3bca2 100644 --- a/components/abstractions/src/test/java/com/microsoft/kiota/serialization/SerializationHelpersTest.java +++ b/components/abstractions/src/test/java/com/microsoft/kiota/serialization/SerializationHelpersTest.java @@ -111,14 +111,15 @@ void serializesAllValuesInBackedModel() throws IOException { entity.getBackingStore().setIsInitializationCompleted(true); - final String result = KiotaJsonSerialization.serializeAsString(entity, false); + final String result = KiotaJsonSerialization.serializeAsString(false, entity); assertFalse(entity.getBackingStore().getReturnOnlyChangedValues()); assertEquals("{\"id\":\"123\",\"officeLocation\":\"Nairobi\"}", result); final String collectionResult = KiotaJsonSerialization.serializeAsString( - new ArrayList<>(Arrays.asList(entity)), false); + false, + new ArrayList<>(Arrays.asList(entity))); assertEquals("[{\"id\":\"123\",\"officeLocation\":\"Nairobi\"}]", collectionResult); } @@ -138,14 +139,15 @@ void serializesChangedValuesInBackedModel() throws IOException { entity.getBackingStore().setIsInitializationCompleted(true); - final String result = KiotaJsonSerialization.serializeAsString(entity, true); + final String result = KiotaJsonSerialization.serializeAsString(true, entity); assertFalse(entity.getBackingStore().getReturnOnlyChangedValues()); assertEquals("{}", result); final String collectionResult = KiotaJsonSerialization.serializeAsString( - new ArrayList<>(Arrays.asList(entity)), true); + true, + new ArrayList<>(Arrays.asList(entity))); assertEquals("[{}]", collectionResult); } }