Replaced Tail Recursion while while/true loops. (#1019)

This commit is contained in:
Koen De Groote
2017-05-11 22:07:10 +12:00
committed by Rob Bygrave
parent 8cef603d1c
commit 951e517caf
8 changed files with 250 additions and 212 deletions
@@ -79,18 +79,22 @@ class DetermineAggPath {
}
String getManyPath(int pos, DeployBeanDescriptor<?> desc) {
while (true) {
String path = paths[pos];
DeployBeanProperty details = desc.getBeanProperty(path);
if (details instanceof DeployBeanPropertyAssocMany<?>) {
return path(pos);
String path = paths[pos];
DeployBeanProperty details = desc.getBeanProperty(path);
if (details instanceof DeployBeanPropertyAssocMany<?>) {
return path(pos);
} else if (details instanceof DeployBeanPropertyAssocOne<?>) {
DeployBeanPropertyAssocOne<?> one = (DeployBeanPropertyAssocOne<?>) details;
DeployBeanDescriptor<?> targetDesc = one.getTargetDeploy();
return getManyPath(pos + 1, targetDesc);
} else if (details instanceof DeployBeanPropertyAssocOne<?>) {
DeployBeanPropertyAssocOne<?> one = (DeployBeanPropertyAssocOne<?>) details;
DeployBeanDescriptor<?> targetDesc = one.getTargetDeploy();
desc = targetDesc;
pos = pos + 1;
continue;
}
throw new IllegalArgumentException("Can not find path to many in aggregation formula [" + aggregation + "]");
}
throw new IllegalArgumentException("Can not find path to many in aggregation formula [" + aggregation + "]");
}
}
}