Skip to content

Commit

Permalink
#2213 Replace a for loop with a zipped stream
Browse files Browse the repository at this point in the history
  • Loading branch information
homedirectory committed Mar 22, 2024
1 parent 6f7ee5a commit 95dc9d0
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import ua.com.fielden.platform.utils.Pair;

import java.sql.Types;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import static org.apache.commons.lang3.StringUtils.substringBefore;
import static ua.com.fielden.platform.utils.Pair.pair;
import static ua.com.fielden.platform.utils.StreamUtils.zip;

/**
* A utility class to interact with mappings between JDBC SQL types and Hibernate types.
Expand Down Expand Up @@ -59,13 +60,9 @@ public static int jdbcSqlTypeFor(final UserType hibernateUserType) {
}

public static List<Pair<String, Integer>> jdbcSqlTypeFor(final CompositeUserType compositeUserType) {
final List<Pair<String, Integer>> result = new ArrayList<>();

for (int index = 0; index < compositeUserType.getPropertyNames().length; index++) {
result.add(pair(compositeUserType.getPropertyNames()[index], jdbcSqlTypeFor(compositeUserType.getPropertyTypes()[index])));
}

return result;
return zip(Arrays.stream(compositeUserType.getPropertyNames()), Arrays.stream(compositeUserType.getPropertyTypes()),
(name, type) -> pair(name, jdbcSqlTypeFor(type)))
.toList();
}

private HibernateToJdbcSqlTypeCorrespondence() {}
Expand Down

0 comments on commit 95dc9d0

Please sign in to comment.