#593 - Refactor SPI - Move methods from ElPropertyValue to ExpressionPath

This commit is contained in:
Robin Bygrave
2016-03-08 21:21:46 +13:00
parent ba871d6684
commit 57836af5b5
8 changed files with 18 additions and 20 deletions
@@ -178,7 +178,7 @@ public final class BeanFkeyProperty implements ElPropertyValue {
}
@Override
public Object elGetReference(EntityBean bean) {
public Object pathGetNested(Object bean) {
throw new RuntimeException("ElPropertyDeploy only - not implemented");
}
@@ -791,7 +791,8 @@ public class BeanProperty implements ElPropertyValue, Property {
return getValueIntercept((EntityBean)bean);
}
public Object elGetReference(EntityBean bean) {
@Override
public Object pathGetNested(Object bean) {
throw new RuntimeException("Not expected to call this");
}
@@ -463,11 +463,11 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> {
}
@Override
public Object elGetReference(EntityBean bean) {
Object value = getValueIntercept(bean);
public Object pathGetNested(Object bean) {
Object value = getValueIntercept((EntityBean)bean);
if (value == null) {
value = targetDescriptor.createEntityBean();
setValueIntercept(bean, value);
setValueIntercept((EntityBean)bean, value);
}
return value;
}
@@ -143,7 +143,7 @@ public class BeanPropertyCompound extends BeanProperty {
}
@Override
public Object elGetReference(EntityBean bean) {
public Object pathGetNested(Object bean) {
return bean;
}
@@ -72,8 +72,8 @@ public class BeanPropertyCompoundScalar extends BeanProperty {
}
@Override
public Object elGetReference(EntityBean bean) {
return getValue(bean);
public Object pathGetNested(Object bean) {
return pathGet(bean);
}
@Override
@@ -226,12 +226,13 @@ public class ElPropertyChain implements ElPropertyValue {
return bean;
}
public Object elGetReference(EntityBean bean) {
@Override
public Object pathGetNested(Object bean) {
EntityBean prevBean = bean;
Object prevBean = bean;
for (int i = 0; i < last; i++) {
// always return non null prevBean
prevBean = (EntityBean) chain[i].elGetReference(prevBean);
prevBean = chain[i].pathGetNested(prevBean);
}
// try the last step in the chain
return chain[last].pathGet(prevBean);
@@ -240,10 +241,9 @@ public class ElPropertyChain implements ElPropertyValue {
@Override
public void pathSet(Object bean, Object value) {
EntityBean prevBean = (EntityBean)bean;
Object prevBean = bean;
for (int i = 0; i < last; i++) {
// always return non null prevBean
prevBean = (EntityBean) chain[i].elGetReference(prevBean);
prevBean = chain[i].pathGetNested(prevBean);
}
if (prevBean != null) {
if (lastBeanProperty != null) {
@@ -58,6 +58,6 @@ public interface ElPropertyValue extends ElPropertyDeploy, ExpressionPath {
* Return the value ensuring objects prior to the top scalar property are
* automatically populated.
*/
Object elGetReference(EntityBean bean);
Object pathGetNested(Object bean);
}
@@ -33,7 +33,8 @@ public class CtCompoundPropertyElAdapter implements ElPropertyValue {
return value;
}
public Object elGetReference(EntityBean bean) {
@Override
public Object pathGetNested(Object bean) {
return bean;
}
@@ -47,10 +48,6 @@ public class CtCompoundPropertyElAdapter implements ElPropertyValue {
prop.setValue(bean, value);
}
public int getDeployOrder() {
return deployOrder;
}
public String getAssocOneIdExpr(String prefix, String operator) {
throw new RuntimeException("Not Supported or Expected");
}