Skip to content

Commit

Permalink
Removed usage of Stream.concat
Browse files Browse the repository at this point in the history
Check Android compatibility test fails when using Stream.concat, switched to traditional Java method.
  • Loading branch information
mfriesen committed Nov 17, 2024
1 parent 05a58e6 commit c9e39dd
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/** Type adapter that reflects over the fields and methods of a class. */
public final class ReflectiveTypeAdapterFactory implements TypeAdapterFactory {
Expand Down Expand Up @@ -89,9 +87,11 @@ private List<String> getFieldNames(Field f) {
SerializedName annotation = f.getAnnotation(SerializedName.class);
if (annotation == null) {
String fieldName = fieldNamingPolicy.translateName(f);
List<String> alternateNames = fieldNamingPolicy.translateToAlternateNames(f);
return Stream.concat(Stream.of(fieldName), alternateNames.stream())
.collect(Collectors.toList());
List<String> alternates = fieldNamingPolicy.translateToAlternateNames(f);
List<String> fieldNames = new ArrayList<>(alternates.size() + 1);
fieldNames.add(fieldName);
fieldNames.addAll(alternates);
return fieldNames;
}

String serializedName = annotation.value();
Expand Down

0 comments on commit c9e39dd

Please sign in to comment.