Skip to content

Commit fc74fa9

Browse files
committed
DATAJDBC-542 - Polishing.
Initialize map with capacity. Fix generics. Original pull request: spring-projects#218.
1 parent 30a6fb5 commit fc74fa9

File tree

2 files changed

+8
-4
lines changed
  • spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis
  • spring-data-relational/src/main/java/org/springframework/data/jdbc/core/convert

2 files changed

+8
-4
lines changed

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class MyBatisContext {
3737
private final @Nullable Class domainType;
3838
private final Map<String, Object> additionalValues;
3939

40-
public MyBatisContext(@Nullable Object id, @Nullable Object instance, @Nullable Class domainType,
40+
public MyBatisContext(@Nullable Object id, @Nullable Object instance, @Nullable Class<?> domainType,
4141
Map<String, Object> additionalValues) {
4242

4343
this.id = id;
@@ -78,7 +78,7 @@ public Identifier getIdentifier() {
7878

7979
/**
8080
* The entity to act upon. This is {@code null} for queries, since the object doesn't exist before the query.
81-
*
81+
*
8282
* @return Might return {@code null}.
8383
*/
8484
@Nullable

spring-data-relational/src/main/java/org/springframework/data/jdbc/core/convert/Identifier.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.LinkedHashMap;
2828
import java.util.List;
2929
import java.util.Map;
30-
import java.util.Optional;
3130

3231
import org.springframework.data.relational.core.sql.SqlIdentifier;
3332
import org.springframework.util.Assert;
@@ -145,7 +144,7 @@ public Identifier withPart(SqlIdentifier name, Object value, Class<?> targetType
145144
*/
146145
public Map<SqlIdentifier, Object> toMap() {
147146

148-
Map<SqlIdentifier, Object> result = new StringKeyedLinkedHashMap<>();
147+
Map<SqlIdentifier, Object> result = new StringKeyedLinkedHashMap<>(getParts().size());
149148
forEach((name, value, type) -> result.put(name, value));
150149
return result;
151150
}
@@ -216,6 +215,10 @@ public interface IdentifierConsumer {
216215

217216
private static class StringKeyedLinkedHashMap<V> extends LinkedHashMap<SqlIdentifier,V> {
218217

218+
public StringKeyedLinkedHashMap(int initialCapacity) {
219+
super(initialCapacity);
220+
}
221+
219222
@Override
220223
public V get(Object key) {
221224

@@ -227,6 +230,7 @@ public V get(Object key) {
227230
}
228231
}
229232
}
233+
230234
return super.get(key);
231235
}
232236
}

0 commit comments

Comments
 (0)