diff --git a/data-azure-cosmos/src/main/java/io/micronaut/data/cosmos/operations/DefaultReactiveCosmosRepositoryOperations.java b/data-azure-cosmos/src/main/java/io/micronaut/data/cosmos/operations/DefaultReactiveCosmosRepositoryOperations.java index 1fd650b344b..30f899f2a3a 100644 --- a/data-azure-cosmos/src/main/java/io/micronaut/data/cosmos/operations/DefaultReactiveCosmosRepositoryOperations.java +++ b/data-azure-cosmos/src/main/java/io/micronaut/data/cosmos/operations/DefaultReactiveCosmosRepositoryOperations.java @@ -294,7 +294,7 @@ public Flux findAll(@NonNull PreparedQuery pq) { return result.byPage().flatMap(response -> { CosmosUtils.processDiagnostics(cosmosDiagnosticsProcessor, CosmosDiagnosticsProcessor.QUERY_ITEMS, response.getCosmosDiagnostics(), response.getActivityId(), response.getRequestCharge()); - return Flux.fromIterable(response.getResults().stream().map(item -> cosmosSerde.deserialize(item, argument)).collect(Collectors.toList())); + return Flux.fromIterable(response.getResults().stream().map(item -> cosmosSerde.deserialize(item, argument)).toList()); }).onErrorMap(e -> CosmosUtils.cosmosAccessException(cosmosDiagnosticsProcessor, CosmosDiagnosticsProcessor.QUERY_ITEMS, FAILED_TO_QUERY_ITEMS, e)); } @@ -312,7 +312,7 @@ public Flux findAll(@NonNull PreparedQuery pq) { return conversionService.convertRequired(item, resultType); } return null; - }).collect(Collectors.toList())); + }).toList()); }).onErrorMap(e -> CosmosUtils.cosmosAccessException(cosmosDiagnosticsProcessor, CosmosDiagnosticsProcessor.QUERY_ITEMS, FAILED_TO_QUERY_ITEMS, e)); } diff --git a/data-document-model/src/main/java/io/micronaut/data/document/model/query/builder/MongoQueryBuilder.java b/data-document-model/src/main/java/io/micronaut/data/document/model/query/builder/MongoQueryBuilder.java index e8a58bd43d9..093ed53b4bd 100644 --- a/data-document-model/src/main/java/io/micronaut/data/document/model/query/builder/MongoQueryBuilder.java +++ b/data-document-model/src/main/java/io/micronaut/data/document/model/query/builder/MongoQueryBuilder.java @@ -67,7 +67,6 @@ import java.util.function.BiConsumer; import java.util.function.Function; import java.util.regex.Pattern; -import java.util.stream.Collectors; import static java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME; import static java.util.Arrays.asList; @@ -176,7 +175,7 @@ public final class MongoQueryBuilder implements QueryBuilder { String criterionPropertyName = getCriterionPropertyName(criterion.getProperty(), context); if (value instanceof Iterable iterable) { List values = CollectionUtils.iterableToList(iterable); - obj.put(criterionPropertyName, singletonMap("$in", values.stream().map(val -> valueRepresentation(context, propertyPath, val)).collect(Collectors.toList()))); + obj.put(criterionPropertyName, singletonMap("$in", values.stream().map(val -> valueRepresentation(context, propertyPath, val)).toList())); } else { obj.put(criterionPropertyName, singletonMap("$in", singletonList(valueRepresentation(context, propertyPath, value)))); } @@ -187,7 +186,7 @@ public final class MongoQueryBuilder implements QueryBuilder { String criterionPropertyName = getCriterionPropertyName(criterion.getProperty(), context); if (value instanceof Iterable iterable) { List values = CollectionUtils.iterableToList(iterable); - obj.put(criterionPropertyName, singletonMap("$nin", values.stream().map(val -> valueRepresentation(context, propertyPath, val)).collect(Collectors.toList()))); + obj.put(criterionPropertyName, singletonMap("$nin", values.stream().map(val -> valueRepresentation(context, propertyPath, val)).toList())); } else { obj.put(criterionPropertyName, singletonMap("$nin", singletonList(valueRepresentation(context, propertyPath, value)))); } @@ -225,7 +224,7 @@ public final class MongoQueryBuilder implements QueryBuilder { Object criteriaValue; if (value instanceof Iterable iterable) { List values = CollectionUtils.iterableToList(iterable); - criteriaValue = values.stream().map(val -> valueRepresentation(context, propertyPath, val)).collect(Collectors.toList()); + criteriaValue = values.stream().map(val -> valueRepresentation(context, propertyPath, val)).toList(); } else { criteriaValue = singletonList(valueRepresentation(context, propertyPath, value)); } @@ -495,7 +494,7 @@ private void addLookups(Collection joins, QueryState queryState) { } List joined = joins.stream().map(JoinPath::getPath) .sorted((o1, o2) -> Comparator.comparingInt(String::length).thenComparing(String::compareTo).compare(o1, o2)) - .collect(Collectors.toList()); + .toList(); for (String join : joined) { StringJoiner rootPath = new StringJoiner("."); StringJoiner currentEntityPath = new StringJoiner("."); diff --git a/data-document-tck/src/main/groovy/io/micronaut/data/document/tck/AbstractDocumentRepositorySpec.groovy b/data-document-tck/src/main/groovy/io/micronaut/data/document/tck/AbstractDocumentRepositorySpec.groovy index 573bec192ae..fb55c609cda 100644 --- a/data-document-tck/src/main/groovy/io/micronaut/data/document/tck/AbstractDocumentRepositorySpec.groovy +++ b/data-document-tck/src/main/groovy/io/micronaut/data/document/tck/AbstractDocumentRepositorySpec.groovy @@ -1214,7 +1214,7 @@ abstract class AbstractDocumentRepositorySpec extends Specification { @Override List call(TransactionStatus status) throws Exception { try (Stream stream = authorRepository.queryByNameRegex(/.*e.*/)) { - return stream.collect(Collectors.toList()) + return stream.toList() } } }) @@ -1227,7 +1227,7 @@ abstract class AbstractDocumentRepositorySpec extends Specification { @Override List call(TransactionStatus status) throws Exception { try (Stream stream = authorRepository.queryByNameRegex(/.*x.*/)) { - return stream.collect(Collectors.toList()) + return stream.toList() } } }) diff --git a/data-hibernate-jpa/src/test/groovy/io/micronaut/data/hibernate/JpaSpecificationCrudRepositorySpec.groovy b/data-hibernate-jpa/src/test/groovy/io/micronaut/data/hibernate/JpaSpecificationCrudRepositorySpec.groovy index 3e26722d3e0..03b7272e5ea 100644 --- a/data-hibernate-jpa/src/test/groovy/io/micronaut/data/hibernate/JpaSpecificationCrudRepositorySpec.groovy +++ b/data-hibernate-jpa/src/test/groovy/io/micronaut/data/hibernate/JpaSpecificationCrudRepositorySpec.groovy @@ -204,7 +204,7 @@ class JpaSpecificationCrudRepositorySpec extends Specification { def people = [p1, p2, p3, p4, p5] crudRepository.saveAll(people) then:"can be ordered case insensitively" - def peopleIds = people.stream().map(p -> p.getId()).collect(Collectors.toList()) + def peopleIds = people.stream().map(p -> p.getId()).toList() Page personsPaged = crudRepository.findAll(new io.micronaut.data.jpa.repository.criteria.Specification() { @Override Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) { @@ -212,7 +212,7 @@ class JpaSpecificationCrudRepositorySpec extends Specification { } }, Pageable.from(0, 10, Sort.of(new Sort.Order("name", Sort.Order.Direction.ASC, true)))) personsPaged.totalSize == 5 - def personNames = personsPaged.content.stream().map(p -> p.name).collect(Collectors.toList()) + def personNames = personsPaged.content.stream().map(p -> p.name).toList() personNames.size() == 5 personNames[0].toLowerCase() == "a" personNames[1].toLowerCase() == "a" diff --git a/data-hibernate-jpa/src/test/groovy/io/micronaut/data/hibernate/ProjectionSpec.groovy b/data-hibernate-jpa/src/test/groovy/io/micronaut/data/hibernate/ProjectionSpec.groovy index 862c7c010d0..3bf1740b0da 100644 --- a/data-hibernate-jpa/src/test/groovy/io/micronaut/data/hibernate/ProjectionSpec.groovy +++ b/data-hibernate-jpa/src/test/groovy/io/micronaut/data/hibernate/ProjectionSpec.groovy @@ -134,14 +134,14 @@ class ProjectionSpec extends Specification { types.contains(Pet.PetType.CAT) when:"a native query is used" - List names = petRepository.findPetNamesNative().collect(Collectors.toList()) + List names = petRepository.findPetNamesNative().toList() then: names.size() == 3 names.containsAll(["A", "B", "C"]) when:"a native query is used" - types = petRepository.findPetTypesNative().collect(Collectors.toList()) + types = petRepository.findPetTypesNative().toList() then: types.size() == 2 diff --git a/data-jdbc/src/main/java/io/micronaut/data/jdbc/operations/DefaultJdbcRepositoryOperations.java b/data-jdbc/src/main/java/io/micronaut/data/jdbc/operations/DefaultJdbcRepositoryOperations.java index 8995775f59c..7bd6b050707 100644 --- a/data-jdbc/src/main/java/io/micronaut/data/jdbc/operations/DefaultJdbcRepositoryOperations.java +++ b/data-jdbc/src/main/java/io/micronaut/data/jdbc/operations/DefaultJdbcRepositoryOperations.java @@ -125,7 +125,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; -import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -689,7 +688,7 @@ public Iterable updateAll(@NonNull UpdateBatchOperation operation) { op.update(); return op.getEntity(); }) - .collect(Collectors.toList()); + .toList(); } JdbcEntitiesOperations op = new JdbcEntitiesOperations<>(ctx, persistentEntity, operation, storedQuery); op.update(); @@ -751,7 +750,7 @@ public Iterable persistAll(@NonNull InsertBatchOperation operation) { op.persist(); return op.getEntity(); }) - .collect(Collectors.toList()); + .toList(); } else { JdbcEntitiesOperations op = new JdbcEntitiesOperations<>(ctx, persistentEntity, operation, storedQuery, true); op.persist(); diff --git a/data-jdbc/src/test/groovy/io/micronaut/data/jdbc/h2/H2StreamingStatementSpec.groovy b/data-jdbc/src/test/groovy/io/micronaut/data/jdbc/h2/H2StreamingStatementSpec.groovy index c7a3bb81113..b911f94435f 100644 --- a/data-jdbc/src/test/groovy/io/micronaut/data/jdbc/h2/H2StreamingStatementSpec.groovy +++ b/data-jdbc/src/test/groovy/io/micronaut/data/jdbc/h2/H2StreamingStatementSpec.groovy @@ -37,7 +37,7 @@ class H2StreamingStatementSpec extends Specification { personRepository.save(new Person(name: 'd')) when: - def list = personRepository.findAllAndStream().collect(Collectors.toList()) + def list = personRepository.findAllAndStream().toList() then: list.size() == 4 diff --git a/data-model/src/main/java/io/micronaut/data/model/Page.java b/data-model/src/main/java/io/micronaut/data/model/Page.java index 9dd670252db..7f8181d1dfc 100644 --- a/data-model/src/main/java/io/micronaut/data/model/Page.java +++ b/data-model/src/main/java/io/micronaut/data/model/Page.java @@ -28,7 +28,6 @@ import java.util.Collections; import java.util.List; import java.util.function.Function; -import java.util.stream.Collectors; /** * Inspired by the Spring Data's {@code Page} and GORM's {@code PagedResultList}, this models a type that supports @@ -72,7 +71,7 @@ default int getTotalPages() { */ @Override default @NonNull Page map(Function function) { - List content = getContent().stream().map(function).collect(Collectors.toList()); + List content = getContent().stream().map(function).toList(); return new DefaultPage<>(content, getPageable(), getTotalSize()); } diff --git a/data-model/src/main/java/io/micronaut/data/model/PersistentEntity.java b/data-model/src/main/java/io/micronaut/data/model/PersistentEntity.java index e844e1d0530..793edfd3eee 100644 --- a/data-model/src/main/java/io/micronaut/data/model/PersistentEntity.java +++ b/data-model/src/main/java/io/micronaut/data/model/PersistentEntity.java @@ -15,6 +15,8 @@ */ package io.micronaut.data.model; +import io.micronaut.core.annotation.NonNull; +import io.micronaut.core.annotation.Nullable; import io.micronaut.core.beans.BeanIntrospection; import io.micronaut.core.naming.NameUtils; import io.micronaut.core.util.ArgumentUtils; @@ -24,11 +26,13 @@ import io.micronaut.data.model.naming.NamingStrategy; import io.micronaut.data.model.runtime.RuntimePersistentEntity; -import io.micronaut.core.annotation.NonNull; -import io.micronaut.core.annotation.Nullable; - -import java.util.*; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Optional; import static io.micronaut.data.model.AssociationUtils.CAMEL_CASE_SPLIT_PATTERN; @@ -139,7 +143,7 @@ default Collection getAssociations() { .stream() .filter(bp -> bp instanceof Association) .map(bp -> (Association) bp) - .collect(Collectors.toList()); + .toList(); } /** @@ -152,7 +156,7 @@ default Collection getAssociations() { return getPersistentProperties().stream() .filter(p -> p instanceof Embedded) .map(p -> (Embedded) p) - .collect(Collectors.toList()); + .toList(); } /** @@ -236,7 +240,7 @@ default String getSimpleName() { default Optional getPath(String camelCasePath) { List path = Arrays.stream(CAMEL_CASE_SPLIT_PATTERN.split(camelCasePath)) .map(NameUtils::decapitalize) - .collect(Collectors.toList()); + .toList(); if (CollectionUtils.isNotEmpty(path)) { Iterator i = path.iterator(); diff --git a/data-model/src/main/java/io/micronaut/data/model/Slice.java b/data-model/src/main/java/io/micronaut/data/model/Slice.java index 155504e1444..c7aa0e0fc29 100644 --- a/data-model/src/main/java/io/micronaut/data/model/Slice.java +++ b/data-model/src/main/java/io/micronaut/data/model/Slice.java @@ -27,7 +27,6 @@ import java.util.Iterator; import java.util.List; import java.util.function.Function; -import java.util.stream.Collectors; /** * Inspired by the Spring Data's {@code Slice} and GORM's {@code PagedResultList}, this models a type that supports @@ -127,7 +126,7 @@ default Iterator iterator() { * @return A new slice with the mapped content */ default @NonNull Slice map(Function function) { - List content = getContent().stream().map(function).collect(Collectors.toList()); + List content = getContent().stream().map(function).toList(); return new DefaultSlice<>(content, getPageable()); } diff --git a/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/AbstractPersistentEntityCriteriaDelete.java b/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/AbstractPersistentEntityCriteriaDelete.java index 05aeae35350..d9d84909a69 100644 --- a/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/AbstractPersistentEntityCriteriaDelete.java +++ b/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/AbstractPersistentEntityCriteriaDelete.java @@ -42,7 +42,6 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.stream.Collectors; /** * The abstract implementation of {@link PersistentEntityCriteriaDelete}. @@ -117,7 +116,7 @@ public PersistentEntityCriteriaDelete where(Predicate... restrictions) { Objects.requireNonNull(restrictions); if (restrictions.length > 0) { predicate = restrictions.length == 1 ? restrictions[0] : new ConjunctionPredicate( - Arrays.stream(restrictions).sequential().map(x -> (IExpression) x).collect(Collectors.toList()) + Arrays.stream(restrictions).sequential().map(x -> (IExpression) x).toList() ); } else { predicate = null; diff --git a/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/AbstractPersistentEntityCriteriaQuery.java b/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/AbstractPersistentEntityCriteriaQuery.java index 2aab0476e7b..369a08dfb4a 100644 --- a/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/AbstractPersistentEntityCriteriaQuery.java +++ b/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/AbstractPersistentEntityCriteriaQuery.java @@ -51,7 +51,6 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; import static io.micronaut.data.model.jpa.criteria.impl.CriteriaUtils.hasVersionPredicate; import static io.micronaut.data.model.jpa.criteria.impl.CriteriaUtils.notSupportedOperation; @@ -118,7 +117,7 @@ public QueryModel getQueryModel() { return Sort.Order.asc(name); } return Sort.Order.desc(name); - }).collect(Collectors.toList()); + }).toList(); qm.sort(Sort.of(sortOrders)); } for (Map.Entry e : joiner.getJoins().entrySet()) { @@ -214,7 +213,7 @@ public PersistentEntityCriteriaQuery where(Predicate... restrictions) { Objects.requireNonNull(restrictions); if (restrictions.length > 0) { predicate = restrictions.length == 1 ? restrictions[0] : new ConjunctionPredicate( - Arrays.stream(restrictions).sequential().map(x -> (IExpression) x).collect(Collectors.toList()) + Arrays.stream(restrictions).sequential().map(x -> (IExpression) x).toList() ); } else { predicate = null; diff --git a/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/AbstractPersistentEntityCriteriaUpdate.java b/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/AbstractPersistentEntityCriteriaUpdate.java index 65f6e1bb76f..3a85ad355ca 100644 --- a/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/AbstractPersistentEntityCriteriaUpdate.java +++ b/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/AbstractPersistentEntityCriteriaUpdate.java @@ -47,7 +47,6 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; import static io.micronaut.data.model.jpa.criteria.impl.CriteriaUtils.notSupportedOperation; import static io.micronaut.data.model.jpa.criteria.impl.CriteriaUtils.requireParameter; @@ -175,7 +174,7 @@ public PersistentEntityCriteriaUpdate where(Predicate... restrictions) { Objects.requireNonNull(restrictions); if (restrictions.length > 0) { predicate = restrictions.length == 1 ? restrictions[0] : new ConjunctionPredicate( - Arrays.stream(restrictions).sequential().map(x -> (IExpression) x).collect(Collectors.toList()) + Arrays.stream(restrictions).sequential().map(x -> (IExpression) x).toList() ); } else { predicate = null; diff --git a/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/CriteriaUtils.java b/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/CriteriaUtils.java index 0d5300e9e24..9de8d888327 100644 --- a/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/CriteriaUtils.java +++ b/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/CriteriaUtils.java @@ -33,7 +33,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; /** * Criteria util class. @@ -63,7 +62,7 @@ public static boolean isComparable(@NonNull Class clazz) { } public static List> requireBoolExpressions(Iterable> restrictions) { - return CollectionUtils.iterableToList(restrictions).stream().map(CriteriaUtils::requireBoolExpression).collect(Collectors.toList()); + return CollectionUtils.iterableToList(restrictions).stream().map(CriteriaUtils::requireBoolExpression).toList(); } public static IExpression requireBoolExpression(Expression exp) { diff --git a/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/query/QueryModelPredicateVisitor.java b/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/query/QueryModelPredicateVisitor.java index 6da1f11f3a7..37197064e05 100644 --- a/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/query/QueryModelPredicateVisitor.java +++ b/data-model/src/main/java/io/micronaut/data/model/jpa/criteria/impl/query/QueryModelPredicateVisitor.java @@ -45,7 +45,6 @@ import java.util.Iterator; import java.util.List; import java.util.StringJoiner; -import java.util.stream.Collectors; /** * The predicate visitor to convert criteria predicates to {@link QueryModel}. @@ -323,12 +322,12 @@ public void visit(PersistentPropertyInValuesPredicate inValues) { state.negated = false; add(Restrictions.notIn( getPropertyPath(inValues), - values.stream().map(this::asValue).collect(Collectors.toList()) + values.stream().map(this::asValue).toList() )); } else { add(Restrictions.in( getPropertyPath(inValues), - values.stream().map(this::asValue).collect(Collectors.toList()) + values.stream().map(this::asValue).toList() )); } } diff --git a/data-model/src/main/java/io/micronaut/data/model/query/builder/AbstractSqlLikeQueryBuilder.java b/data-model/src/main/java/io/micronaut/data/model/query/builder/AbstractSqlLikeQueryBuilder.java index 8492ab4bd6b..88d80655729 100644 --- a/data-model/src/main/java/io/micronaut/data/model/query/builder/AbstractSqlLikeQueryBuilder.java +++ b/data-model/src/main/java/io/micronaut/data/model/query/builder/AbstractSqlLikeQueryBuilder.java @@ -377,7 +377,7 @@ private CriterionHandler likeConcatC } } return (Runnable) () -> query.append(p); - }).collect(Collectors.toList())); + }).toList()); }; } diff --git a/data-model/src/main/java/io/micronaut/data/model/query/builder/sql/SqlQueryBuilder.java b/data-model/src/main/java/io/micronaut/data/model/query/builder/sql/SqlQueryBuilder.java index 38fc7203bc4..3288c33b532 100644 --- a/data-model/src/main/java/io/micronaut/data/model/query/builder/sql/SqlQueryBuilder.java +++ b/data-model/src/main/java/io/micronaut/data/model/query/builder/sql/SqlQueryBuilder.java @@ -766,7 +766,7 @@ private List getJoinedColumns(AnnotationMetadata annotationMetadata, boo .stream() .map(ann -> ann.stringValue(columnType).orElse(null)) .filter(Objects::nonNull) - .collect(Collectors.toList()); + .toList(); } return Collections.emptyList(); } @@ -780,7 +780,7 @@ private Collection getJoinTableAssociations(PersistentEntity persis return isForeignKeyWithJoinTable(a); } return false; - }).map(p -> (Association) p).collect(Collectors.toList()); + }).map(p -> (Association) p).toList(); } @Override @@ -803,7 +803,7 @@ protected void selectAllColumnsFromJoinPaths(QueryState queryState, Map joinAliasOverride) { if (CollectionUtils.isNotEmpty(allPaths)) { - Collection joinPaths = allPaths.stream().filter(jp -> jp.getJoinType().isFetch()).collect(Collectors.toList()); + Collection joinPaths = allPaths.stream().filter(jp -> jp.getJoinType().isFetch()).toList(); if (CollectionUtils.isNotEmpty(joinPaths)) { for (JoinPath joinPath : joinPaths) { @@ -1466,10 +1466,10 @@ protected void buildJoin(String joinType, List associationJoinColumns = resolveJoinTableAssociatedColumns(annotationMetadata, !isAssociationOwner, associatedEntity, namingStrategy); List associationJoinTableColumns = resolveJoinTableJoinColumns(annotationMetadata, !isAssociationOwner, associatedEntity, namingStrategy); if (escape) { - ownerJoinColumns = ownerJoinColumns.stream().map(this::quote).collect(Collectors.toList()); - ownerJoinTableColumns = ownerJoinTableColumns.stream().map(this::quote).collect(Collectors.toList()); - associationJoinColumns = associationJoinColumns.stream().map(this::quote).collect(Collectors.toList()); - associationJoinTableColumns = associationJoinTableColumns.stream().map(this::quote).collect(Collectors.toList()); + ownerJoinColumns = ownerJoinColumns.stream().map(this::quote).toList(); + ownerJoinTableColumns = ownerJoinTableColumns.stream().map(this::quote).toList(); + associationJoinColumns = associationJoinColumns.stream().map(this::quote).toList(); + associationJoinTableColumns = associationJoinTableColumns.stream().map(this::quote).toList(); } String joinTableSchema = annotationMetadata @@ -1613,8 +1613,8 @@ private void join(StringBuilder sb, getTableName(associatedEntity), rightTableAlias, leftTableAlias, - escape ? onLeftColumns.stream().map(this::quote).collect(Collectors.toList()) : onLeftColumns, - escape ? onRightColumns.stream().map(this::quote).collect(Collectors.toList()) : onRightColumns + escape ? onLeftColumns.stream().map(this::quote).toList() : onLeftColumns, + escape ? onRightColumns.stream().map(this::quote).toList() : onRightColumns ); } diff --git a/data-model/src/main/java/io/micronaut/data/operations/RepositoryOperations.java b/data-model/src/main/java/io/micronaut/data/operations/RepositoryOperations.java index cc38a690651..65d9c024321 100644 --- a/data-model/src/main/java/io/micronaut/data/operations/RepositoryOperations.java +++ b/data-model/src/main/java/io/micronaut/data/operations/RepositoryOperations.java @@ -34,7 +34,6 @@ import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -166,7 +165,7 @@ public interface RepositoryOperations extends HintsCapableRepository, Applicatio default Iterable updateAll(@NonNull UpdateBatchOperation operation) { return operation.split().stream() .map(this::update) - .collect(Collectors.toList()); + .toList(); } /** @@ -179,7 +178,7 @@ default Iterable updateAll(@NonNull UpdateBatchOperation operation) { default Iterable persistAll(@NonNull InsertBatchOperation operation) { return operation.split().stream() .map(this::persist) - .collect(Collectors.toList()); + .toList(); } /** diff --git a/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/AbstractMongoRepositoryOperations.java b/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/AbstractMongoRepositoryOperations.java index ccfcf38b8ee..dbe85c599b8 100644 --- a/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/AbstractMongoRepositoryOperations.java +++ b/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/AbstractMongoRepositoryOperations.java @@ -57,7 +57,6 @@ import java.util.Map; import java.util.Optional; import java.util.function.Supplier; -import java.util.stream.Collectors; /** * Shared implementation of Mongo sync and reactive repositories. @@ -252,7 +251,7 @@ protected void logAggregate(MongoAggregation aggregation) { StringBuilder sb = new StringBuilder("Executing Mongo 'aggregate'"); if (options != null) { sb.append(" with"); - sb.append(" pipeline: ").append(aggregation.getPipeline().stream().map(e -> e.toBsonDocument().toJson()).collect(Collectors.toList())); + sb.append(" pipeline: ").append(aggregation.getPipeline().stream().map(e -> e.toBsonDocument().toJson()).toList()); Collation collation = options.getCollation(); if (collation != null) { sb.append(" collation: ").append(collation); diff --git a/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/DefaultMongoRepositoryOperations.java b/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/DefaultMongoRepositoryOperations.java index c0b453c9bbf..47d219045a1 100644 --- a/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/DefaultMongoRepositoryOperations.java +++ b/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/DefaultMongoRepositoryOperations.java @@ -189,7 +189,7 @@ private R getCount(ClientSession clientSession, MongoPreparedQuery if (preparedQuery.isAggregate()) { MongoAggregation aggregation = preparedQuery.getAggregation(); if (QUERY_LOG.isDebugEnabled()) { - QUERY_LOG.debug("Executing Mongo 'aggregate' with pipeline: {}", aggregation.getPipeline().stream().map(e -> e.toBsonDocument().toJson()).collect(Collectors.toList())); + QUERY_LOG.debug("Executing Mongo 'aggregate' with pipeline: {}", aggregation.getPipeline().stream().map(e -> e.toBsonDocument().toJson()).toList()); } R result = aggregate(clientSession, preparedQuery, BsonDocument.class) .map(bsonDocument -> convertResult(database.getCodecRegistry(), resultType, bsonDocument, false)) @@ -907,7 +907,7 @@ protected void collectAutoPopulatedPreviousValues() { @Override protected void execute() throws RuntimeException { - List filters = entities.stream().filter(d -> !d.vetoed).map(d -> this.filters.get(d)).collect(Collectors.toList()); + List filters = entities.stream().filter(d -> !d.vetoed).map(d -> this.filters.get(d)).toList(); if (!filters.isEmpty()) { Bson filter = Filters.or(filters); if (QUERY_LOG.isDebugEnabled()) { @@ -957,7 +957,7 @@ private MongoEntitiesOperation createMongoInsertManyOperation(MongoOperat @Override protected void execute() throws RuntimeException { - List toInsert = entities.stream().filter(d -> !d.vetoed).map(d -> d.entity).collect(Collectors.toList()); + List toInsert = entities.stream().filter(d -> !d.vetoed).map(d -> d.entity).toList(); if (toInsert.isEmpty()) { return; } diff --git a/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/DefaultMongoStoredQuery.java b/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/DefaultMongoStoredQuery.java index b6e0d2daff6..a35681983e2 100644 --- a/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/DefaultMongoStoredQuery.java +++ b/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/DefaultMongoStoredQuery.java @@ -502,7 +502,7 @@ private BsonValue getValue(QueryParameterBinding queryParameterBinding, Object v return new BsonObjectId(new ObjectId(string)); } return MongoUtils.toBsonValue(conversionService, val, codecRegistry.get()); - }).collect(Collectors.toList())); + }).toList()); } return MongoUtils.toBsonValue(conversionService, value, codecRegistry.get()); } diff --git a/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/DefaultReactiveMongoRepositoryOperations.java b/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/DefaultReactiveMongoRepositoryOperations.java index cf7a4c66bdd..776d2ab4aa6 100644 --- a/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/DefaultReactiveMongoRepositoryOperations.java +++ b/data-mongodb/src/main/java/io/micronaut/data/mongodb/operations/DefaultReactiveMongoRepositoryOperations.java @@ -84,7 +84,6 @@ import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.function.Predicate; -import java.util.stream.Collectors; /** * The reactive MongoDB repository operations implementation. @@ -347,7 +346,7 @@ private Mono getCount(ClientSession clientSession, MongoPreparedQuery< if (preparedQuery.isAggregate()) { MongoAggregation aggregation = preparedQuery.getAggregation(); if (QUERY_LOG.isDebugEnabled()) { - QUERY_LOG.debug("Executing Mongo 'aggregate' with pipeline: {}", aggregation.getPipeline().stream().map(e -> e.toBsonDocument().toJson()).collect(Collectors.toList())); + QUERY_LOG.debug("Executing Mongo 'aggregate' with pipeline: {}", aggregation.getPipeline().stream().map(e -> e.toBsonDocument().toJson()).toList()); } return Mono.from(aggregate(clientSession, preparedQuery, BsonDocument.class).first()) .map(bsonDocument -> convertResult(database.getCodecRegistry(), resultType, bsonDocument, false)) @@ -896,7 +895,7 @@ protected void collectAutoPopulatedPreviousValues() { @Override protected void execute() throws RuntimeException { Mono, Long>> entitiesWithRowsUpdated = entities.flatMap(list -> { - List filters = list.stream().filter(d -> !d.vetoed).map(d -> ((Bson) d.filter)).collect(Collectors.toList()); + List filters = list.stream().filter(d -> !d.vetoed).map(d -> ((Bson) d.filter)).toList(); Mono modifiedCount; if (!filters.isEmpty()) { Bson filter = Filters.or(filters); @@ -957,7 +956,7 @@ private MongoReactiveEntitiesOperation createMongoInsertManyOperation(Mon @Override protected void execute() throws RuntimeException { entities = entities.flatMap(list -> { - List toInsert = list.stream().filter(d -> !d.vetoed).map(d -> d.entity).collect(Collectors.toList()); + List toInsert = list.stream().filter(d -> !d.vetoed).map(d -> d.entity).toList(); if (toInsert.isEmpty()) { return Mono.just(list); } diff --git a/data-mongodb/src/test/groovy/io/micronaut/data/document/mongodb/MongoDocumentRepositorySpec.groovy b/data-mongodb/src/test/groovy/io/micronaut/data/document/mongodb/MongoDocumentRepositorySpec.groovy index 535eeb2fe50..fd959797c44 100644 --- a/data-mongodb/src/test/groovy/io/micronaut/data/document/mongodb/MongoDocumentRepositorySpec.groovy +++ b/data-mongodb/src/test/groovy/io/micronaut/data/document/mongodb/MongoDocumentRepositorySpec.groovy @@ -437,7 +437,7 @@ class MongoDocumentRepositorySpec extends AbstractDocumentRepositorySpec impleme assert person != null def optPerson = personRepository.findById(person.id) def personsByIdIn = personRepository.findByIdIn(Arrays.asList(person.id)) - def personsByIdNotInIds = personRepository.findByIdNotIn(Arrays.asList(person.id)).stream().map(p -> p.id).collect(Collectors.toList()) + def personsByIdNotInIds = personRepository.findByIdNotIn(Arrays.asList(person.id)).stream().map(p -> p.id).toList() then: optPerson.present optPerson.get().id == person.id diff --git a/data-processor/src/main/java/io/micronaut/data/processor/visitors/MappedEntityVisitor.java b/data-processor/src/main/java/io/micronaut/data/processor/visitors/MappedEntityVisitor.java index ac0e6df2335..512ff589ba5 100644 --- a/data-processor/src/main/java/io/micronaut/data/processor/visitors/MappedEntityVisitor.java +++ b/data-processor/src/main/java/io/micronaut/data/processor/visitors/MappedEntityVisitor.java @@ -45,7 +45,6 @@ import java.util.Objects; import java.util.Optional; import java.util.function.Function; -import java.util.stream.Collectors; import static io.micronaut.data.processor.visitors.Utils.getConfiguredDataConverters; import static io.micronaut.data.processor.visitors.Utils.getConfiguredDataTypes; @@ -107,7 +106,7 @@ public void visitClass(ClassElement element, VisitorContext context) { final List> indexes = properties.stream() .flatMap(prop -> prop.findAnnotation(Index.class).stream()) - .collect(Collectors.toList()); + .toList(); if (!indexes.isEmpty()) { element.annotate(Indexes.class, builder -> builder.values(indexes.toArray(new AnnotationValue[]{}))); diff --git a/data-processor/src/main/java/io/micronaut/data/processor/visitors/MethodMatchContext.java b/data-processor/src/main/java/io/micronaut/data/processor/visitors/MethodMatchContext.java index 25fede971eb..8cdeebe931d 100644 --- a/data-processor/src/main/java/io/micronaut/data/processor/visitors/MethodMatchContext.java +++ b/data-processor/src/main/java/io/micronaut/data/processor/visitors/MethodMatchContext.java @@ -29,7 +29,6 @@ import java.util.List; import java.util.Map; import java.util.function.Function; -import java.util.stream.Collectors; /** * A match context for finding a matching method. @@ -110,7 +109,7 @@ public SourcePersistentEntity getRootEntity() { public @NonNull List getParametersNotInRole() { return Arrays.stream(getParameters()).filter(p -> !this.parametersInRole.containsValue(p) - ).collect(Collectors.toList()); + ).toList(); } /** diff --git a/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/AbstractCriteriaMethodMatch.java b/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/AbstractCriteriaMethodMatch.java index 7c25d27148f..0633d69fc12 100644 --- a/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/AbstractCriteriaMethodMatch.java +++ b/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/AbstractCriteriaMethodMatch.java @@ -73,7 +73,6 @@ import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; /** * Abstract criteria matcher. @@ -103,7 +102,7 @@ public abstract class AbstractCriteriaMethodMatch implements MethodMatcher.Metho PROPERTY_RESTRICTIONS = Restrictions.PROPERTY_RESTRICTIONS_MAP.keySet() .stream() .sorted(Comparator.comparingInt(String::length).thenComparing(String.CASE_INSENSITIVE_ORDER).reversed()) - .collect(Collectors.toList()); + .toList(); List restrictionElements = new ArrayList<>(Restrictions.RESTRICTIONS_MAP.keySet()); restrictionElements.sort(Comparator.comparingInt(String::length).thenComparing(String.CASE_INSENSITIVE_ORDER).reversed()); String rExpressionPattern = String.join("|", restrictionElements); diff --git a/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/Projections.java b/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/Projections.java index 38cf9696381..5be4f11ece9 100644 --- a/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/Projections.java +++ b/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/Projections.java @@ -31,7 +31,6 @@ import java.util.List; import java.util.Optional; import java.util.function.BiFunction; -import java.util.stream.Collectors; /** * Projections. @@ -50,7 +49,7 @@ public final class Projections { } catch (Throwable e) { return null; } - }).collect(Collectors.toList()); + }).toList(); @Nullable public static Selection find(@NonNull PersistentEntityRoot entityRoot, diff --git a/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/RawQueryMethodMatcher.java b/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/RawQueryMethodMatcher.java index 1dc5e307e1e..0ead0fbb9e3 100644 --- a/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/RawQueryMethodMatcher.java +++ b/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/RawQueryMethodMatcher.java @@ -384,7 +384,6 @@ private static SourceParameterExpressionImpl bindingParameter(MethodMatchContext type); } - /** * Extract the expression type. * @param matchContext The match context diff --git a/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/Restrictions.java b/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/Restrictions.java index fcd6b4ff604..9ff95a1d601 100644 --- a/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/Restrictions.java +++ b/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/Restrictions.java @@ -49,7 +49,7 @@ public final class Restrictions { } catch (Throwable e) { return null; } - }).collect(Collectors.toList()); + }).toList(); private static final List RESTRICTIONS_LIST = Arrays.stream(Restrictions.class.getClasses()) .filter(clazz -> Restriction.class.isAssignableFrom(clazz) && !Modifier.isAbstract(clazz.getModifiers())) @@ -59,7 +59,7 @@ public final class Restrictions { } catch (Throwable e) { return null; } - }).collect(Collectors.toList()); + }).toList(); public static final Map PROPERTY_RESTRICTIONS_MAP = PROPERTY_RESTRICTIONS_LIST.stream() .collect(Collectors.toMap(PropertyRestriction::getName, p -> p, (a, b) -> a, TreeMap::new)); diff --git a/data-r2dbc/src/main/java/io/micronaut/data/r2dbc/config/R2dbcSchemaGenerator.java b/data-r2dbc/src/main/java/io/micronaut/data/r2dbc/config/R2dbcSchemaGenerator.java index 2a69e3e1722..3c694fc3226 100644 --- a/data-r2dbc/src/main/java/io/micronaut/data/r2dbc/config/R2dbcSchemaGenerator.java +++ b/data-r2dbc/src/main/java/io/micronaut/data/r2dbc/config/R2dbcSchemaGenerator.java @@ -41,7 +41,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; /** * Schema generation for R2DBC. @@ -122,7 +121,7 @@ protected void createSchema(BeanLocator beanLocator) { private Mono generate(Connection connection, SchemaGenerate schemaGenerate, PersistentEntity[] entities, SqlQueryBuilder builder) { List createStatements = Arrays.stream(entities) .flatMap(entity -> Arrays.stream(builder.buildCreateTableStatements(entity))) - .collect(Collectors.toList()); + .toList(); Flux createTablesFlow = Flux.fromIterable(createStatements) .concatMap(sql -> { if (DataSettings.QUERY_LOG.isDebugEnabled()) { @@ -139,7 +138,7 @@ private Mono generate(Connection connection, SchemaGenerate schemaGenerate return switch (schemaGenerate) { case CREATE_DROP -> { List dropStatements = Arrays.stream(entities).flatMap(entity -> Arrays.stream(builder.buildDropTableStatements(entity))) - .collect(Collectors.toList()); + .toList(); yield Flux.fromIterable(dropStatements) .concatMap(sql -> { if (DataSettings.QUERY_LOG.isDebugEnabled()) { diff --git a/data-r2dbc/src/main/java/io/micronaut/data/r2dbc/operations/DefaultR2dbcRepositoryOperations.java b/data-r2dbc/src/main/java/io/micronaut/data/r2dbc/operations/DefaultR2dbcRepositoryOperations.java index 66cfde33d25..6fbc82f2616 100644 --- a/data-r2dbc/src/main/java/io/micronaut/data/r2dbc/operations/DefaultR2dbcRepositoryOperations.java +++ b/data-r2dbc/src/main/java/io/micronaut/data/r2dbc/operations/DefaultR2dbcRepositoryOperations.java @@ -119,7 +119,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; import java.util.function.Predicate; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -319,7 +318,7 @@ private Mono sum(Stream> stream) { } private Flux concatMono(Stream> stream) { - return Flux.concat(stream.collect(Collectors.toList())); + return Flux.concat(stream.toList()); } @NonNull @@ -1064,7 +1063,7 @@ protected void execute() throws RuntimeException { if (hasGeneratedId) { entities = entities .flatMap(list -> { - List notVetoedEntities = list.stream().filter(this::notVetoed).collect(Collectors.toList()); + List notVetoedEntities = list.stream().filter(this::notVetoed).toList(); if (notVetoedEntities.isEmpty()) { return Mono.just(notVetoedEntities); } diff --git a/data-runtime/src/main/java/io/micronaut/data/runtime/criteria/LiteralsAsParametersQueryModelPredicateVisitor.java b/data-runtime/src/main/java/io/micronaut/data/runtime/criteria/LiteralsAsParametersQueryModelPredicateVisitor.java index 063bcc6b9bf..0c9051717d1 100644 --- a/data-runtime/src/main/java/io/micronaut/data/runtime/criteria/LiteralsAsParametersQueryModelPredicateVisitor.java +++ b/data-runtime/src/main/java/io/micronaut/data/runtime/criteria/LiteralsAsParametersQueryModelPredicateVisitor.java @@ -32,7 +32,6 @@ import java.util.List; import java.util.Objects; import java.util.Set; -import java.util.stream.Collectors; /** * Variation of {@link QueryModelPredicateVisitor} that converts literal query values to query parameters. @@ -126,8 +125,8 @@ private Set> asCollectionParameter(Collection values) { throw new IllegalStateException("Expected to have all literal values"); } return new LiteralExpression(v); - }).collect(Collectors.toList()); - List literalValues = literals.stream().map(LiteralExpression::getValue).collect(Collectors.toList()); + }).toList(); + List literalValues = literals.stream().map(LiteralExpression::getValue).toList(); Class javaType = (Class) literals.iterator().next().getJavaType(); return Collections.singleton(criteriaBuilder.parameter(javaType, null, literalValues)); } diff --git a/data-runtime/src/main/java/io/micronaut/data/runtime/event/EntityEventRegistry.java b/data-runtime/src/main/java/io/micronaut/data/runtime/event/EntityEventRegistry.java index f23cb36b1b8..4d831f5f9d8 100644 --- a/data-runtime/src/main/java/io/micronaut/data/runtime/event/EntityEventRegistry.java +++ b/data-runtime/src/main/java/io/micronaut/data/runtime/event/EntityEventRegistry.java @@ -72,7 +72,7 @@ public EntityEventRegistry(BeanContext beanContext) { //noinspection RedundantCast this.allEventListeners = beanContext.getBeanDefinitions(EntityEventListener.class) .stream().filter(bd -> ((Class) bd.getBeanType()) != (Class) getClass()) - .collect(Collectors.toList()); + .toList(); } @Override diff --git a/data-runtime/src/main/java/io/micronaut/data/runtime/http/PageableRequestArgumentBinder.java b/data-runtime/src/main/java/io/micronaut/data/runtime/http/PageableRequestArgumentBinder.java index 8660e6c4af3..df037e6344b 100644 --- a/data-runtime/src/main/java/io/micronaut/data/runtime/http/PageableRequestArgumentBinder.java +++ b/data-runtime/src/main/java/io/micronaut/data/runtime/http/PageableRequestArgumentBinder.java @@ -31,7 +31,6 @@ import java.util.Locale; import java.util.Optional; import java.util.function.Function; -import java.util.stream.Collectors; /** * A request argument binder for binding a {@link Pageable} object from the request. @@ -92,7 +91,7 @@ public BindingResult bind(ArgumentConversionContext context, List orders = sortParams.stream() .map(sortMapper) - .collect(Collectors.toList()); + .toList(); sort = Sort.of(orders); } diff --git a/data-runtime/src/main/java/io/micronaut/data/runtime/intercept/criteria/AbstractSpecificationInterceptor.java b/data-runtime/src/main/java/io/micronaut/data/runtime/intercept/criteria/AbstractSpecificationInterceptor.java index 4cca0c74517..cfbf53fbcc6 100644 --- a/data-runtime/src/main/java/io/micronaut/data/runtime/intercept/criteria/AbstractSpecificationInterceptor.java +++ b/data-runtime/src/main/java/io/micronaut/data/runtime/intercept/criteria/AbstractSpecificationInterceptor.java @@ -64,7 +64,6 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; @@ -73,7 +72,7 @@ import java.util.function.Function; import java.util.stream.Collectors; -import static io.micronaut.data.model.runtime.StoredQuery.*; +import static io.micronaut.data.model.runtime.StoredQuery.OperationType; /** * Abstract specification interceptor. diff --git a/data-runtime/src/main/java/io/micronaut/data/runtime/operations/internal/AbstractSyncEntitiesOperations.java b/data-runtime/src/main/java/io/micronaut/data/runtime/operations/internal/AbstractSyncEntitiesOperations.java index e53f01faa16..65cdaa4ba6b 100644 --- a/data-runtime/src/main/java/io/micronaut/data/runtime/operations/internal/AbstractSyncEntitiesOperations.java +++ b/data-runtime/src/main/java/io/micronaut/data/runtime/operations/internal/AbstractSyncEntitiesOperations.java @@ -32,7 +32,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -89,7 +88,7 @@ protected AbstractSyncEntitiesOperations(Ctx ctx, Data d = new Data(); d.entity = entity; return d; - }).collect(Collectors.toList()); + }).toList(); } @Override @@ -158,7 +157,7 @@ protected void triggerPost(Consumer> fn) { @Override public List getEntities() { - return entities.stream().map(d -> d.entity).collect(Collectors.toList()); + return entities.stream().map(d -> d.entity).toList(); } @SuppressWarnings("VisibilityModifier") diff --git a/data-runtime/src/main/java/io/micronaut/data/runtime/operations/internal/sql/AbstractSqlRepositoryOperations.java b/data-runtime/src/main/java/io/micronaut/data/runtime/operations/internal/sql/AbstractSqlRepositoryOperations.java index 38cd84088a2..12dfa7f0291 100644 --- a/data-runtime/src/main/java/io/micronaut/data/runtime/operations/internal/sql/AbstractSqlRepositoryOperations.java +++ b/data-runtime/src/main/java/io/micronaut/data/runtime/operations/internal/sql/AbstractSqlRepositoryOperations.java @@ -83,10 +83,9 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiFunction; -import java.util.stream.Collectors; import java.util.stream.Stream; -import static io.micronaut.data.model.runtime.StoredQuery.*; +import static io.micronaut.data.model.runtime.StoredQuery.OperationType; /** * Abstract SQL repository implementation not specifically bound to JDBC. @@ -364,7 +363,7 @@ protected SqlStoredQuery resolveEntityUpdate(AnnotationMetadata annota p.getAnnotationMetadata().booleanValue(AutoPopulated.class, "updateable").orElse(true) ) .map(PersistentProperty::getName) - .collect(Collectors.toList()); + .toList(); final QueryResult queryResult = queryBuilder.buildUpdate(annotationMetadata, queryModel, updateProperties); return new DefaultSqlStoredQuery<>(QueryResultStoredQuery.single(OperationType.UPDATE, "Custom update", AnnotationMetadata.EMPTY_METADATA, queryResult, rootEntity), persistentEntity, queryBuilder); }); @@ -384,7 +383,7 @@ protected SqlStoredQuery resolveEntityUpdate(AnnotationMetadata annota String sqlInsert = resolveAssociationInsert(repositoryType, persistentEntity, association); final SqlQueryBuilder queryBuilder = findQueryBuilder(repositoryType); List parameters = new ArrayList<>(); - for (Map.Entry property : idPropertiesWithValues(persistentEntity.getIdentity(), entity).collect(Collectors.toList())) { + for (Map.Entry property : idPropertiesWithValues(persistentEntity.getIdentity(), entity).toList()) { parameters.add(new QueryParameterBinding() { @Override diff --git a/data-spring/src/main/java/io/micronaut/data/spring/runtime/http/SpringPageableRequestArgumentBinder.java b/data-spring/src/main/java/io/micronaut/data/spring/runtime/http/SpringPageableRequestArgumentBinder.java index e4008c9a28d..3124c9a0a9e 100644 --- a/data-spring/src/main/java/io/micronaut/data/spring/runtime/http/SpringPageableRequestArgumentBinder.java +++ b/data-spring/src/main/java/io/micronaut/data/spring/runtime/http/SpringPageableRequestArgumentBinder.java @@ -32,7 +32,6 @@ import java.util.Locale; import java.util.Optional; import java.util.function.Function; -import java.util.stream.Collectors; /** * Spring version of pageable binder. @@ -94,7 +93,7 @@ public BindingResult bind(ArgumentConversionContext context, List orders = sortParams.stream() .map(sortMapper) - .collect(Collectors.toList()); + .toList(); sort = Sort.by(orders); } else { sort = Sort.unsorted(); diff --git a/data-tck/src/main/groovy/io/micronaut/data/tck/tests/AbstractRepositorySpec.groovy b/data-tck/src/main/groovy/io/micronaut/data/tck/tests/AbstractRepositorySpec.groovy index bfbb14e1a19..fe2e7f6194f 100644 --- a/data-tck/src/main/groovy/io/micronaut/data/tck/tests/AbstractRepositorySpec.groovy +++ b/data-tck/src/main/groovy/io/micronaut/data/tck/tests/AbstractRepositorySpec.groovy @@ -1116,7 +1116,7 @@ abstract class AbstractRepositorySpec extends Specification { List authors = transactionManager.get().executeRead(new TransactionCallback>() { @Override List call(TransactionStatus status) throws Exception { - authorRepository.queryByNameContains("e").collect(Collectors.toList()) + authorRepository.queryByNameContains("e").toList() } }) @@ -1127,7 +1127,7 @@ abstract class AbstractRepositorySpec extends Specification { List emptyAuthors = transactionManager.get().executeRead(new TransactionCallback>() { @Override List call(TransactionStatus status) throws Exception { - authorRepository.queryByNameContains("x").collect(Collectors.toList()) + authorRepository.queryByNameContains("x").toList() } }) @@ -1395,7 +1395,7 @@ abstract class AbstractRepositorySpec extends Specification { def authors = transactionManager.get().executeRead(new TransactionCallback>() { @Override List call(TransactionStatus status) throws Exception { - authorRepository.queryByIdIsNotNull().collect(Collectors.toList()) + authorRepository.queryByIdIsNotNull().toList() } }) diff --git a/doc-examples/jdbc-and-r2dbc-example-java/src/main/java/example/AbstractJdbcBookRepository.java b/doc-examples/jdbc-and-r2dbc-example-java/src/main/java/example/AbstractJdbcBookRepository.java index 209ff004aab..f485c5a0e67 100644 --- a/doc-examples/jdbc-and-r2dbc-example-java/src/main/java/example/AbstractJdbcBookRepository.java +++ b/doc-examples/jdbc-and-r2dbc-example-java/src/main/java/example/AbstractJdbcBookRepository.java @@ -26,7 +26,7 @@ public List findByTitle(String title) { return jdbcOperations.prepareStatement(sql, statement -> { statement.setString(1, title); ResultSet resultSet = statement.executeQuery(); - return jdbcOperations.entityStream(resultSet, Book.class).collect(Collectors.toList()); + return jdbcOperations.entityStream(resultSet, Book.class).toList(); }); } } diff --git a/doc-examples/jdbc-example-groovy/src/main/groovy/example/AbstractBookRepository.groovy b/doc-examples/jdbc-example-groovy/src/main/groovy/example/AbstractBookRepository.groovy index 18fc7afea4e..b7574f692ee 100644 --- a/doc-examples/jdbc-example-groovy/src/main/groovy/example/AbstractBookRepository.groovy +++ b/doc-examples/jdbc-example-groovy/src/main/groovy/example/AbstractBookRepository.groovy @@ -26,7 +26,7 @@ abstract class AbstractBookRepository implements CrudRepository { statement.setString(1, title) ResultSet resultSet = statement.executeQuery() return jdbcOperations.entityStream(resultSet, Book.class) - .collect(Collectors.toList()) + .toList() }) } } diff --git a/doc-examples/jdbc-example-java/src/main/java/example/AbstractBookRepository.java b/doc-examples/jdbc-example-java/src/main/java/example/AbstractBookRepository.java index 3ae98f4e265..bd994ed9b66 100644 --- a/doc-examples/jdbc-example-java/src/main/java/example/AbstractBookRepository.java +++ b/doc-examples/jdbc-example-java/src/main/java/example/AbstractBookRepository.java @@ -26,7 +26,7 @@ public List findByTitle(String title) { return jdbcOperations.prepareStatement(sql, statement -> { statement.setString(1, title); ResultSet resultSet = statement.executeQuery(); - return jdbcOperations.entityStream(resultSet, Book.class).collect(Collectors.toList()); + return jdbcOperations.entityStream(resultSet, Book.class).toList(); }); } } diff --git a/doc-examples/jdbc-multitenancy-datasource-example-java/src/main/java/example/BookController.java b/doc-examples/jdbc-multitenancy-datasource-example-java/src/main/java/example/BookController.java index e016a972cc4..36b9fd4d077 100644 --- a/doc-examples/jdbc-multitenancy-datasource-example-java/src/main/java/example/BookController.java +++ b/doc-examples/jdbc-multitenancy-datasource-example-java/src/main/java/example/BookController.java @@ -33,7 +33,7 @@ Optional findOne(Long id) { @Get List findAll() { - return bookRepository.findAll().stream().map(BookDto::new).collect(Collectors.toList()); + return bookRepository.findAll().stream().map(BookDto::new).toList(); } @Delete diff --git a/doc-examples/jdbc-multitenancy-schema-example-java/src/main/java/example/BookController.java b/doc-examples/jdbc-multitenancy-schema-example-java/src/main/java/example/BookController.java index e016a972cc4..36b9fd4d077 100644 --- a/doc-examples/jdbc-multitenancy-schema-example-java/src/main/java/example/BookController.java +++ b/doc-examples/jdbc-multitenancy-schema-example-java/src/main/java/example/BookController.java @@ -33,7 +33,7 @@ Optional findOne(Long id) { @Get List findAll() { - return bookRepository.findAll().stream().map(BookDto::new).collect(Collectors.toList()); + return bookRepository.findAll().stream().map(BookDto::new).toList(); } @Delete diff --git a/doc-examples/mongo-multitenancy-database-example-java/src/main/java/example/BookController.java b/doc-examples/mongo-multitenancy-database-example-java/src/main/java/example/BookController.java index 7151c6348ef..d4dcfb13f07 100644 --- a/doc-examples/mongo-multitenancy-database-example-java/src/main/java/example/BookController.java +++ b/doc-examples/mongo-multitenancy-database-example-java/src/main/java/example/BookController.java @@ -35,7 +35,7 @@ Optional findOne(String id) { @Get List findAll() { - List collect = bookRepository.findAll().stream().map(BookDto::new).collect(Collectors.toList()); + List collect = bookRepository.findAll().stream().map(BookDto::new).toList(); System.out.println(ServerRequestContext.currentRequest().get().getHeaders().get("tenantId") + " " + collect); return collect; } diff --git a/doc-examples/mongo-multitenancy-datasource-example-java/src/main/java/example/BookController.java b/doc-examples/mongo-multitenancy-datasource-example-java/src/main/java/example/BookController.java index 2b96a5bf586..6f417f3a474 100644 --- a/doc-examples/mongo-multitenancy-datasource-example-java/src/main/java/example/BookController.java +++ b/doc-examples/mongo-multitenancy-datasource-example-java/src/main/java/example/BookController.java @@ -34,7 +34,7 @@ Optional findOne(String id) { @Get List findAll() { - return bookRepository.findAll().stream().map(BookDto::new).collect(Collectors.toList()); + return bookRepository.findAll().stream().map(BookDto::new).toList(); } @Delete