mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Java language level updates concerning Maps. (#1008)
* Java language level updates concerning Maps. * Reverts when comments indicated no sync can happen.
This commit is contained in:
committed by
Rob Bygrave
parent
8432f7b0d5
commit
43408fcb87
@@ -696,11 +696,7 @@ public class BaseTableDdl implements TableDdl {
|
||||
*/
|
||||
protected void regenerateHistoryTriggers(String baseTableName, HistoryTableUpdate.Change change, String column) {
|
||||
|
||||
HistoryTableUpdate update = regenerateHistoryTriggers.get(baseTableName);
|
||||
if (update == null) {
|
||||
update = new HistoryTableUpdate(baseTableName);
|
||||
regenerateHistoryTriggers.put(baseTableName, update);
|
||||
}
|
||||
HistoryTableUpdate update = regenerateHistoryTriggers.computeIfAbsent(baseTableName, HistoryTableUpdate::new);
|
||||
update.add(change, column);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,7 @@ public class PendingDrops {
|
||||
*/
|
||||
public void add(MigrationVersion version, ChangeSet changeSet) {
|
||||
|
||||
Entry entry = map.get(version.normalised());
|
||||
if (entry == null) {
|
||||
entry = new Entry(version);
|
||||
map.put(version.normalised(), entry);
|
||||
}
|
||||
Entry entry = map.computeIfAbsent(version.normalised(), k -> new Entry(version));
|
||||
entry.add(changeSet);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,11 +89,7 @@ public class PathProperties implements FetchPath {
|
||||
}
|
||||
|
||||
Props getProps(String path) {
|
||||
Props props = pathMap.get(path);
|
||||
if (props == null) {
|
||||
props = new Props(this, null, path);
|
||||
pathMap.put(path, props);
|
||||
}
|
||||
Props props = pathMap.computeIfAbsent(path, p -> new Props(this, null, p));
|
||||
return props;
|
||||
}
|
||||
|
||||
|
||||
@@ -169,11 +169,7 @@ public class BindParams implements Serializable {
|
||||
}
|
||||
|
||||
private Param getParam(String name) {
|
||||
Param p = namedParameters.get(name);
|
||||
if (p == null) {
|
||||
p = new Param();
|
||||
namedParameters.put(name, p);
|
||||
}
|
||||
Param p = namedParameters.computeIfAbsent(name, k -> new Param());
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,11 +103,7 @@ public class ProfileManager implements ProfilingListener {
|
||||
|
||||
private ProfileOrigin getProfileOrigin(ObjectGraphOrigin originQueryPoint) {
|
||||
synchronized (monitor) {
|
||||
ProfileOrigin stats = profileMap.get(originQueryPoint.getKey());
|
||||
if (stats == null) {
|
||||
stats = new ProfileOrigin(originQueryPoint, queryTuningAddVersion, profilingBase, profilingRate);
|
||||
profileMap.put(originQueryPoint.getKey(), stats);
|
||||
}
|
||||
ProfileOrigin stats = profileMap.computeIfAbsent(originQueryPoint.getKey(), k -> new ProfileOrigin(originQueryPoint, queryTuningAddVersion, profilingBase, profilingRate));
|
||||
return stats;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,11 +122,7 @@ public class CacheChangeSet {
|
||||
*/
|
||||
private ManyChange many(BeanDescriptor<?> desc, String manyProperty) {
|
||||
ManyKey key = new ManyKey(desc, manyProperty);
|
||||
ManyChange manyChange = manyChangeMap.get(key);
|
||||
if (manyChange == null) {
|
||||
manyChange = new ManyChange(key);
|
||||
manyChangeMap.put(key, manyChange);
|
||||
}
|
||||
ManyChange manyChange = manyChangeMap.computeIfAbsent(key, ManyChange::new);
|
||||
return manyChange;
|
||||
}
|
||||
|
||||
|
||||
@@ -1996,11 +1996,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo, BeanType<T> {
|
||||
}
|
||||
|
||||
public ElComparator<T> getElComparator(String propNameOrSortBy) {
|
||||
ElComparator<T> c = comparatorCache.get(propNameOrSortBy);
|
||||
if (c == null) {
|
||||
c = createComparator(propNameOrSortBy);
|
||||
comparatorCache.put(propNameOrSortBy, c);
|
||||
}
|
||||
ElComparator<T> c = comparatorCache.computeIfAbsent(propNameOrSortBy, this::createComparator);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
@@ -481,11 +481,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
String baseTable = desc.getBaseTable();
|
||||
if (baseTable != null) {
|
||||
baseTable = baseTable.toLowerCase();
|
||||
List<BeanDescriptor<?>> list = tableToDescMap.get(baseTable);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>(1);
|
||||
tableToDescMap.put(baseTable, list);
|
||||
}
|
||||
List<BeanDescriptor<?>> list = tableToDescMap.computeIfAbsent(baseTable, k -> new ArrayList<>(1));
|
||||
list.add(desc);
|
||||
}
|
||||
if (desc.getEntityType() == EntityType.VIEW && desc.isQueryCaching()) {
|
||||
@@ -495,11 +491,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
|
||||
if (dependentTables != null && dependentTables.length > 0) {
|
||||
for (String depTable : dependentTables) {
|
||||
depTable = depTable.toLowerCase();
|
||||
List<BeanDescriptor<?>> list = tableToViewDescMap.get(depTable);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>(1);
|
||||
tableToViewDescMap.put(depTable, list);
|
||||
}
|
||||
List<BeanDescriptor<?>> list = tableToViewDescMap.computeIfAbsent(depTable, k -> new ArrayList<>(1));
|
||||
list.add(desc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,11 +79,7 @@ class PrepareDocNested {
|
||||
for (int i = 0; i < origSize; i++) {
|
||||
SpiExpression expr = origUnderlying.get(i);
|
||||
String nestedPath = expr.nestedPath(beanDescriptor);
|
||||
Group group = groups.get(nestedPath);
|
||||
if (group == null) {
|
||||
group = new Group(nestedPath);
|
||||
groups.put(nestedPath, group);
|
||||
}
|
||||
Group group = groups.computeIfAbsent(nestedPath, Group::new);
|
||||
group.list.add(expr);
|
||||
}
|
||||
|
||||
|
||||
@@ -211,11 +211,7 @@ public class DLoadContext implements LoadContext {
|
||||
@Override
|
||||
public ObjectGraphNode getObjectGraphNode(String path) {
|
||||
|
||||
ObjectGraphNode node = nodePathMap.get(path);
|
||||
if (node == null) {
|
||||
node = createObjectGraphNode(path);
|
||||
nodePathMap.put(path, node);
|
||||
}
|
||||
ObjectGraphNode node = nodePathMap.computeIfAbsent(path, this::createObjectGraphNode);
|
||||
|
||||
return node;
|
||||
}
|
||||
@@ -284,11 +280,7 @@ public class DLoadContext implements LoadContext {
|
||||
if (path == null) {
|
||||
return rootBeanContext;
|
||||
}
|
||||
DLoadBeanContext beanContext = beanMap.get(path);
|
||||
if (beanContext == null) {
|
||||
beanContext = createBeanContext(path, defaultBatchSize, null);
|
||||
beanMap.put(path, beanContext);
|
||||
}
|
||||
DLoadBeanContext beanContext = beanMap.computeIfAbsent(path, p -> createBeanContext(p, defaultBatchSize, null));
|
||||
return beanContext;
|
||||
}
|
||||
|
||||
@@ -314,11 +306,7 @@ public class DLoadContext implements LoadContext {
|
||||
if (path == null) {
|
||||
throw new RuntimeException("path is null?");
|
||||
}
|
||||
DLoadManyContext ctx = manyMap.get(path);
|
||||
if (ctx == null) {
|
||||
ctx = createManyContext(path, defaultBatchSize, null);
|
||||
manyMap.put(path, ctx);
|
||||
}
|
||||
DLoadManyContext ctx = manyMap.computeIfAbsent(path, p -> createManyContext(p, defaultBatchSize, null));
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
@@ -1568,11 +1568,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
namedParams = new HashMap<>();
|
||||
}
|
||||
|
||||
ONamedParam param = namedParams.get(name);
|
||||
if (param == null) {
|
||||
param = new ONamedParam(name);
|
||||
namedParams.put(name, param);
|
||||
}
|
||||
ONamedParam param = namedParams.computeIfAbsent(name, ONamedParam::new);
|
||||
return param;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,11 +39,7 @@ public final class BeanPersistIdMap {
|
||||
|
||||
private BeanPersistIds getPersistIds(BeanDescriptor<?> desc) {
|
||||
String beanType = desc.getFullName();
|
||||
BeanPersistIds r = beanMap.get(beanType);
|
||||
if (r == null) {
|
||||
r = new BeanPersistIds(desc);
|
||||
beanMap.put(beanType, r);
|
||||
}
|
||||
BeanPersistIds r = beanMap.computeIfAbsent(beanType, k -> new BeanPersistIds(desc));
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,7 @@ public class BulkEventListenerMap {
|
||||
|
||||
private void register(String tableName, BulkTableEventListener l) {
|
||||
String upperTableName = tableName.trim().toUpperCase();
|
||||
Entry entry = map.get(upperTableName);
|
||||
if (entry == null) {
|
||||
entry = new Entry();
|
||||
map.put(upperTableName, entry);
|
||||
}
|
||||
Entry entry = map.computeIfAbsent(upperTableName, k -> new Entry());
|
||||
entry.add(l);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,11 +68,7 @@ public final class DeleteByIdMap {
|
||||
|
||||
private BeanPersistIds getPersistIds(BeanDescriptor<?> desc) {
|
||||
String beanType = desc.getFullName();
|
||||
BeanPersistIds r = beanMap.get(beanType);
|
||||
if (r == null) {
|
||||
r = new BeanPersistIds(desc);
|
||||
beanMap.put(beanType, r);
|
||||
}
|
||||
BeanPersistIds r = beanMap.computeIfAbsent(beanType, k -> new BeanPersistIds(desc));
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.ebeaninternal.api.SpiTransaction;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -14,7 +15,7 @@ public class TransactionMap {
|
||||
/**
|
||||
* Map of State by serverName.
|
||||
*/
|
||||
private final HashMap<String, State> map = new HashMap<>();
|
||||
private final Map<String, State> map = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -38,11 +39,7 @@ public class TransactionMap {
|
||||
*/
|
||||
public State getStateWithCreate(String serverName) {
|
||||
|
||||
State state = map.get(serverName);
|
||||
if (state == null) {
|
||||
state = new State();
|
||||
map.put(serverName, state);
|
||||
}
|
||||
State state = map.computeIfAbsent(serverName, k -> new State());
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user