Skip to content

Commit

Permalink
Change usages of <stream>.toList() to `<stream>.collect(Collectors.…
Browse files Browse the repository at this point in the history
…toList())`

Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Jun 6, 2024
1 parent 779b09f commit e461c39
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ public class Field {
@Nullable
private final Deprecation deprecation;

public Field(@Nonnull String wireName, @Nonnull Type type, boolean required, @Nullable String description, @Nullable Deprecation deprecation) {
public Field(
@Nonnull String wireName,
@Nonnull Type type,
boolean required,
@Nullable String description,
@Nullable Deprecation deprecation
) {
this.wireName = Strings.requireNonBlank(wireName, "wireName must not be null");
this.type = Objects.requireNonNull(type, "type must not be null");
this.required = required;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private HttpPath(@Nonnull List<Part> parts, @Nullable Deprecation deprecation, @
}

public List<Field> getParams() {
return parts.stream().filter(Part::isParameter).map(Part::getParameter).toList();
return parts.stream().filter(Part::isParameter).map(Part::getParameter).collect(Collectors.toList());
}

public Set<String> getParamNameSet() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensearch.client.codegen.JavaFormatter;
Expand Down Expand Up @@ -99,7 +100,11 @@ public String getName() {
}

public Collection<Client> getChildren() {
return parent.children.values().stream().filter(n -> !n.operations.isEmpty()).map(n -> new Client(n, async)).toList();
return parent.children.values()
.stream()
.filter(n -> !n.operations.isEmpty())
.map(n -> new Client(n, async))
.collect(Collectors.toList());
}

public Collection<RequestShape> getOperations() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import org.apache.commons.lang3.NotImplementedException;
Expand Down Expand Up @@ -239,7 +240,7 @@ private void visit(Namespace parent, String className, String typedefName, OpenA
shape = new EnumShape(
parent,
className,
schema.getEnums().orElseThrow().stream().map(EnumShape.Variant::new).toList(),
schema.getEnums().orElseThrow().stream().map(EnumShape.Variant::new).collect(Collectors.toList()),
typedefName
);
} else if (schema.hasOneOf()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

public class TaggedUnionShape extends ObjectShape {
private final List<Variant> variants = new ArrayList<>();
Expand All @@ -28,7 +29,7 @@ public Collection<Variant> getVariants() {
}

public Collection<Variant> getPrimitiveVariants() {
return variants.stream().filter(v -> v.getType().isPrimitive()).toList();
return variants.stream().filter(v -> v.getType().isPrimitive()).collect(Collectors.toList());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public static HttpMethod from(@Nonnull PathItem.HttpMethod httpMethod) {
return from(httpMethod.name().toLowerCase());
}


@Override
public String toString() {
return name().toLowerCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ protected OpenApiParameter(@Nullable OpenApiElement<?> parent, @Nonnull JsonPoin
var extensions = parameter.getExtensions();
this.versionDeprecated = Maps.tryGet(extensions, "x-version-deprecated").map(String::valueOf).orElse(null);
this.deprecationMessage = Maps.tryGet(extensions, "x-deprecation-message").map(String::valueOf).orElse(null);
this.isGlobal = (Boolean) Maps.tryGet(extensions, "x-global")
.orElse(null);
this.isGlobal = (Boolean) Maps.tryGet(extensions, "x-global").orElse(null);
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static <TOld, TNew> List<TNew> transform(@Nonnull List<TOld> list, @Nonnu
public static <TOld, TNew> List<TNew> transform(@Nonnull List<TOld> list, @Nonnull ItemMapper<TOld, TNew> function) {
Objects.requireNonNull(list, "list must not be null");
Objects.requireNonNull(function, "function must not be null");
return IntStream.range(0, list.size()).mapToObj(i -> function.map(i, list.get(i))).toList();
return IntStream.range(0, list.size()).mapToObj(i -> function.map(i, list.get(i))).collect(Collectors.toList());
}

@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public Set<File> resolve(boolean withTransitives, @Nonnull Collection<String> ma

var dependencies = mavenCoordinates.stream()
.map(coord -> new Dependency(new DefaultArtifact(coord), null, null, withTransitives ? null : EXCLUDE_ALL_TRANSITIVES))
.toList();
.collect(Collectors.toList());

var request = new DependencyRequest(new CollectRequest(dependencies, null, repositories), null);

Expand Down

0 comments on commit e461c39

Please sign in to comment.