Skip to content

Commit

Permalink
Fix android linting failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndiritu committed Oct 4, 2024
1 parent 3b96a38 commit aac05d3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ private KiotaJsonSerialization() {}
* @throws IOException when the stream cannot be closed or read.
*/
@Nonnull public static <T extends Parsable> 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);
}

/**
Expand All @@ -61,9 +61,9 @@ private KiotaJsonSerialization() {}
* @throws IOException when the stream cannot be closed or read.
*/
@Nonnull public static <T extends Parsable> 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);
}

/**
Expand All @@ -87,10 +87,10 @@ private KiotaJsonSerialization() {}
* @throws IOException when the stream cannot be closed or read.
*/
@Nonnull public static <T extends Parsable> InputStream serializeAsStream(
@Nonnull final Iterable<T> values, final boolean serializeOnlyChangedValues)
final boolean serializeOnlyChangedValues, @Nonnull final Iterable<T> values)
throws IOException {
return KiotaSerialization.serializeAsStream(
CONTENT_TYPE, values, serializeOnlyChangedValues);
CONTENT_TYPE, serializeOnlyChangedValues, values);
}

/**
Expand All @@ -114,10 +114,10 @@ private KiotaJsonSerialization() {}
* @throws IOException when the stream cannot be closed or read.
*/
@Nonnull public static <T extends Parsable> String serializeAsString(
@Nonnull final Iterable<T> values, final boolean serializeOnlyChangedValues)
final boolean serializeOnlyChangedValues, @Nonnull final Iterable<T> values)
throws IOException {
return KiotaSerialization.serializeAsString(
CONTENT_TYPE, values, serializeOnlyChangedValues);
CONTENT_TYPE, serializeOnlyChangedValues, values);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private KiotaSerialization() {}
*/
@Nonnull public static <T extends Parsable> 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);
}

/**
Expand All @@ -44,8 +44,8 @@ private KiotaSerialization() {}
*/
@Nonnull public static <T extends Parsable> 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 =
Expand All @@ -66,7 +66,7 @@ private KiotaSerialization() {}
@Nonnull public static <T extends Parsable> 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);
}

/**
Expand All @@ -80,12 +80,12 @@ private KiotaSerialization() {}
*/
@Nonnull public static <T extends Parsable> 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);
}
}
Expand All @@ -102,7 +102,7 @@ private KiotaSerialization() {}
@Nonnull final String contentType, @Nonnull final Iterable<T> values)
throws IOException {
Objects.requireNonNull(values);
return serializeAsStream(contentType, values, DEFAULT_SERIALIZE_ONLY_CHANGED_VALUES);
return serializeAsStream(contentType, DEFAULT_SERIALIZE_ONLY_CHANGED_VALUES, values);
}

/**
Expand All @@ -116,8 +116,8 @@ private KiotaSerialization() {}
*/
@Nonnull public static <T extends Parsable> InputStream serializeAsStream(
@Nonnull final String contentType,
@Nonnull final Iterable<T> values,
final boolean serializeOnlyChangedValues)
final boolean serializeOnlyChangedValues,
@Nonnull final Iterable<T> values)
throws IOException {
Objects.requireNonNull(values);
try (final SerializationWriter writer =
Expand All @@ -139,7 +139,7 @@ private KiotaSerialization() {}
@Nonnull final String contentType, @Nonnull final Iterable<T> values)
throws IOException {
Objects.requireNonNull(values);
return serializeAsString(contentType, values, DEFAULT_SERIALIZE_ONLY_CHANGED_VALUES);
return serializeAsString(contentType, DEFAULT_SERIALIZE_ONLY_CHANGED_VALUES, values);
}

/**
Expand All @@ -153,12 +153,12 @@ private KiotaSerialization() {}
*/
@Nonnull public static <T extends Parsable> String serializeAsString(
@Nonnull final String contentType,
@Nonnull final Iterable<T> values,
final boolean serializeOnlyChangedValues)
final boolean serializeOnlyChangedValues,
@Nonnull final Iterable<T> 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
}

0 comments on commit aac05d3

Please sign in to comment.