DATAJDBC-542 - Polishing.

Initialize map with capacity. Fix generics.

Original pull request: #218.
This commit is contained in:
Mark Paluch
2020-05-14 10:40:57 +02:00
parent 30a6fb5654
commit fc74fa9975
2 changed files with 8 additions and 4 deletions

View File

@@ -37,7 +37,7 @@ public class MyBatisContext {
private final @Nullable Class domainType;
private final Map<String, Object> additionalValues;
public MyBatisContext(@Nullable Object id, @Nullable Object instance, @Nullable Class domainType,
public MyBatisContext(@Nullable Object id, @Nullable Object instance, @Nullable Class<?> domainType,
Map<String, Object> additionalValues) {
this.id = id;
@@ -78,7 +78,7 @@ public class MyBatisContext {
/**
* The entity to act upon. This is {@code null} for queries, since the object doesn't exist before the query.
*
*
* @return Might return {@code null}.
*/
@Nullable

View File

@@ -27,7 +27,6 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.springframework.data.relational.core.sql.SqlIdentifier;
import org.springframework.util.Assert;
@@ -145,7 +144,7 @@ public final class Identifier {
*/
public Map<SqlIdentifier, Object> toMap() {
Map<SqlIdentifier, Object> result = new StringKeyedLinkedHashMap<>();
Map<SqlIdentifier, Object> result = new StringKeyedLinkedHashMap<>(getParts().size());
forEach((name, value, type) -> result.put(name, value));
return result;
}
@@ -216,6 +215,10 @@ public final class Identifier {
private static class StringKeyedLinkedHashMap<V> extends LinkedHashMap<SqlIdentifier,V> {
public StringKeyedLinkedHashMap(int initialCapacity) {
super(initialCapacity);
}
@Override
public V get(Object key) {
@@ -227,6 +230,7 @@ public final class Identifier {
}
}
}
return super.get(key);
}
}