mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor tidy internals - aList -> expr in for loops etc. No functional change.
This commit is contained in:
@@ -92,9 +92,7 @@ public class LoadBeanRequest extends LoadRequest {
|
||||
* Return the list of Id values for the beans in the lazy load buffer.
|
||||
*/
|
||||
public List<Object> getIdList() {
|
||||
|
||||
List<Object> idList = new ArrayList<>();
|
||||
|
||||
BeanDescriptor<?> desc = loadBuffer.getBeanDescriptor();
|
||||
for (EntityBeanIntercept ebi : batch) {
|
||||
idList.add(desc.getId(ebi.getOwner()));
|
||||
@@ -106,10 +104,8 @@ public class LoadBeanRequest extends LoadRequest {
|
||||
* Configure the query for lazy loading execution.
|
||||
*/
|
||||
public void configureQuery(SpiQuery<?> query, List<Object> idList) {
|
||||
|
||||
query.setMode(SpiQuery.Mode.LAZYLOAD_BEAN);
|
||||
query.setPersistenceContext(loadBuffer.getPersistenceContext());
|
||||
|
||||
String mode = isLazy() ? "+lazy" : "+query";
|
||||
query.setLoadDescription(mode, getDescription());
|
||||
|
||||
@@ -117,9 +113,7 @@ public class LoadBeanRequest extends LoadRequest {
|
||||
// cascade the batch size (if set) for further lazy loading
|
||||
query.setLazyLoadBatchSize(getBatchSize());
|
||||
}
|
||||
|
||||
loadBuffer.configureQuery(query, lazyLoadProperty);
|
||||
|
||||
if (idList.size() == 1) {
|
||||
query.where().idEq(idList.get(0));
|
||||
} else {
|
||||
@@ -131,19 +125,16 @@ public class LoadBeanRequest extends LoadRequest {
|
||||
* Load the beans into the L2 cache if that is requested and check for load failures due to deletes.
|
||||
*/
|
||||
public void postLoad(List<?> list) {
|
||||
|
||||
Set<Object> loadedIds = new HashSet<>();
|
||||
|
||||
BeanDescriptor<?> desc = loadBuffer.getBeanDescriptor();
|
||||
// collect Ids and maybe load bean cache
|
||||
for (Object aList : list) {
|
||||
EntityBean loadedBean = (EntityBean) aList;
|
||||
for (Object bean : list) {
|
||||
EntityBean loadedBean = (EntityBean) bean;
|
||||
loadedIds.add(desc.getId(loadedBean));
|
||||
}
|
||||
if (isLoadCache()) {
|
||||
desc.cacheBeanPutAll(list);
|
||||
}
|
||||
|
||||
if (lazyLoadProperty != null) {
|
||||
for (EntityBeanIntercept ebi : batch) {
|
||||
// check if the underlying row in DB was deleted. Mark the bean as 'failed' if
|
||||
|
||||
@@ -2055,17 +2055,15 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
return transactionManager;
|
||||
}
|
||||
|
||||
public void register(BeanPersistController c) {
|
||||
List<BeanDescriptor<?>> list = beanDescriptorManager.getBeanDescriptorList();
|
||||
for (BeanDescriptor<?> aList : list) {
|
||||
aList.register(c);
|
||||
public void register(BeanPersistController controller) {
|
||||
for (BeanDescriptor<?> desc : beanDescriptorManager.getBeanDescriptorList()) {
|
||||
desc.register(controller);
|
||||
}
|
||||
}
|
||||
|
||||
public void deregister(BeanPersistController c) {
|
||||
List<BeanDescriptor<?>> list = beanDescriptorManager.getBeanDescriptorList();
|
||||
for (BeanDescriptor<?> aList : list) {
|
||||
aList.deregister(c);
|
||||
for (BeanDescriptor<?> desc : beanDescriptorManager.getBeanDescriptorList()) {
|
||||
desc.deregister(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -702,13 +702,11 @@ public class DeployBeanDescriptor<T> {
|
||||
}
|
||||
|
||||
public void sortProperties() {
|
||||
|
||||
ArrayList<DeployBeanProperty> list = new ArrayList<>(propMap.values());
|
||||
list.sort(PROP_ORDER);
|
||||
|
||||
propMap = new LinkedHashMap<>(list.size());
|
||||
for (DeployBeanProperty aList : list) {
|
||||
addBeanProperty(aList);
|
||||
for (DeployBeanProperty property : list) {
|
||||
addBeanProperty(property);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-10
@@ -137,10 +137,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
|
||||
@Override
|
||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins whereManyJoins) {
|
||||
list = buildExpressions(desc);
|
||||
if (list != null) {
|
||||
for (SpiExpression aList : list) {
|
||||
aList.containsMany(desc, whereManyJoins);
|
||||
}
|
||||
for (SpiExpression expr : list) {
|
||||
expr.containsMany(desc, whereManyJoins);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,8 +185,8 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
|
||||
|
||||
@Override
|
||||
public void validate(SpiExpressionValidation validation) {
|
||||
for (SpiExpression aList : list) {
|
||||
aList.validate(validation);
|
||||
for (SpiExpression expr : list) {
|
||||
expr.validate(validation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,10 +227,9 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
|
||||
*/
|
||||
@Override
|
||||
public void queryPlanHash(StringBuilder builder) {
|
||||
|
||||
builder.append("Example[");
|
||||
for (SpiExpression aList : list) {
|
||||
aList.queryPlanHash(builder);
|
||||
for (SpiExpression expr : list) {
|
||||
expr.queryPlanHash(builder);
|
||||
builder.append(",");
|
||||
}
|
||||
builder.append("]");
|
||||
@@ -264,7 +261,6 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
|
||||
* Build the List of expressions.
|
||||
*/
|
||||
private ArrayList<SpiExpression> buildExpressions(BeanDescriptor<?> beanDescriptor) {
|
||||
|
||||
ArrayList<SpiExpression> list = new ArrayList<>();
|
||||
addExpressions(list, beanDescriptor, entity, null);
|
||||
return list;
|
||||
|
||||
+16
-22
@@ -110,10 +110,8 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
* @return A single SpiExpression that has the nestedPath set
|
||||
*/
|
||||
SpiExpression wrap(List<SpiExpression> list, String nestedPath, Junction.Type type) {
|
||||
|
||||
DefaultExpressionList<T> wrapper = new DefaultExpressionList<>(query, expr, null, list, false);
|
||||
wrapper.setAllDocNested(nestedPath);
|
||||
|
||||
if (type != null) {
|
||||
return new JunctionExpression<>(type, wrapper);
|
||||
} else {
|
||||
@@ -122,15 +120,15 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
}
|
||||
|
||||
void simplifyEntries() {
|
||||
for (SpiExpression element : list) {
|
||||
element.simplify();
|
||||
for (SpiExpression expr : list) {
|
||||
expr.simplify();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prefixProperty(String path) {
|
||||
for (SpiExpression exp : list) {
|
||||
exp.prefixProperty(path);
|
||||
for (SpiExpression expr : list) {
|
||||
expr.prefixProperty(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +173,6 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
context.startNested(allDocNestedPath);
|
||||
}
|
||||
int size = list.size();
|
||||
|
||||
SpiExpression first = list.get(0);
|
||||
boolean explicitBool = first instanceof SpiJunction<?>;
|
||||
boolean implicitBool = !explicitBool && size > 1;
|
||||
@@ -211,7 +208,6 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
|
||||
@Override
|
||||
public void writeDocQuery(DocQueryContext context, SpiExpression idEquals) throws IOException {
|
||||
|
||||
if (allDocNestedPath != null) {
|
||||
context.startNested(allDocNestedPath);
|
||||
}
|
||||
@@ -228,8 +224,8 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
if (idEquals != null) {
|
||||
idEquals.writeDocQuery(context);
|
||||
}
|
||||
for (SpiExpression aList : list) {
|
||||
aList.writeDocQuery(context);
|
||||
for (SpiExpression expr : list) {
|
||||
expr.writeDocQuery(context);
|
||||
}
|
||||
context.endBool();
|
||||
}
|
||||
@@ -279,16 +275,15 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
*/
|
||||
@Override
|
||||
public void containsMany(BeanDescriptor<?> desc, ManyWhereJoins whereManyJoins) {
|
||||
|
||||
for (SpiExpression aList : list) {
|
||||
aList.containsMany(desc, whereManyJoins);
|
||||
for (SpiExpression expr : list) {
|
||||
expr.containsMany(desc, whereManyJoins);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(SpiExpressionValidation validation) {
|
||||
for (SpiExpression aList : list) {
|
||||
aList.validate(validation);
|
||||
for (SpiExpression expr : list) {
|
||||
expr.validate(validation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,7 +626,6 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
|
||||
@Override
|
||||
public void addSql(SpiExpressionRequest request) {
|
||||
|
||||
for (int i = 0, size = list.size(); i < size; i++) {
|
||||
SpiExpression expression = list.get(i);
|
||||
if (i > 0) {
|
||||
@@ -643,15 +637,15 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
|
||||
@Override
|
||||
public void addBindValues(SpiExpressionRequest request) {
|
||||
for (SpiExpression aList : list) {
|
||||
aList.addBindValues(request);
|
||||
for (SpiExpression expr : list) {
|
||||
expr.addBindValues(request);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareExpression(BeanQueryRequest<?> request) {
|
||||
for (SpiExpression aList : list) {
|
||||
aList.prepareExpression(request);
|
||||
for (SpiExpression expr : list) {
|
||||
expr.prepareExpression(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -668,8 +662,8 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
if (allDocNestedPath != null) {
|
||||
builder.append("path:").append(allDocNestedPath).append(" ");
|
||||
}
|
||||
for (SpiExpression aList : list) {
|
||||
aList.queryPlanHash(builder);
|
||||
for (SpiExpression expr : list) {
|
||||
expr.queryPlanHash(builder);
|
||||
builder.append(",");
|
||||
}
|
||||
builder.append("]");
|
||||
|
||||
@@ -207,9 +207,8 @@ class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expression
|
||||
@Override
|
||||
public void queryPlanHash(StringBuilder builder) {
|
||||
builder.append(type).append("[");
|
||||
List<SpiExpression> list = exprList.internalList();
|
||||
for (SpiExpression aList : list) {
|
||||
aList.queryPlanHash(builder);
|
||||
for (SpiExpression expr : exprList.internalList()) {
|
||||
expr.queryPlanHash(builder);
|
||||
builder.append(",");
|
||||
}
|
||||
builder.append("]");
|
||||
|
||||
Reference in New Issue
Block a user