Add Period support via CompoundTypePeriod, rename server/reflect to server/properties

This commit is contained in:
rbygrave committed 2014-11-18 23:09:26 +13:00
1 parent 98f6e1e6af
commit 07cdb69a5b
27 files changed
+501 -333

No files matched your search

@@ -6,93 +6,100 @@ import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanProperty;
import com.avaje.ebeaninternal.server.type.CtCompoundProperty;
/**
* A BeanProperty owned by a Compound value object that maps to
* A BeanProperty owned by a Compound value object that maps to
* a real scalar type.
*
* @author rbygrave
*/
public class BeanPropertyCompoundScalar extends BeanProperty {
private final BeanPropertyCompoundRoot rootProperty;
private final CtCompoundProperty ctProperty;
@SuppressWarnings("rawtypes")
private final ScalarTypeConverter typeConverter;
public BeanPropertyCompoundScalar(BeanPropertyCompoundRoot rootProperty, DeployBeanProperty scalarDeploy,
CtCompoundProperty ctProperty, ScalarTypeConverter<?, ?> typeConverter) {
super(scalarDeploy);
this.rootProperty = rootProperty;
this.ctProperty = ctProperty;
this.typeConverter = typeConverter;
}
private final BeanPropertyCompoundRoot rootProperty;
@SuppressWarnings("unchecked")
@Override
public Object getValue(EntityBean valueObject) {
Object val = valueObject;
if (typeConverter != null){
val = typeConverter.unwrapValue(val);
}
return ctProperty.getValue(val);
}
private final CtCompoundProperty ctProperty;
@Override
public void setValue(EntityBean bean, Object value) {
setValueInCompound(bean, value, false);
}
@SuppressWarnings("unchecked")
public void setValueInCompound(EntityBean bean, Object value, boolean intercept) {
Object compoundValue = ctProperty.setValue(bean, value);
if (compoundValue != null){
if (typeConverter != null){
compoundValue = typeConverter.wrapValue(compoundValue);
}
// we are at the top level and we have a compound value
// that we can set using the root property
if (intercept){
rootProperty.setRootValueIntercept(bean, compoundValue);
} else {
rootProperty.setRootValue(bean, compoundValue);
}
}
}
@SuppressWarnings("rawtypes")
private final ScalarTypeConverter typeConverter;
/**
* No interception on embedded scalar values inside a CVO.
*/
@Override
public void setValueIntercept(EntityBean bean, Object value) {
setValueInCompound(bean, value, true);
}
public BeanPropertyCompoundScalar(BeanPropertyCompoundRoot rootProperty, DeployBeanProperty scalarDeploy,
CtCompoundProperty ctProperty, ScalarTypeConverter<?, ?> typeConverter) {
/**
* No interception on embedded scalar values inside a CVO.
*/
@Override
public Object getValueIntercept(EntityBean bean) {
return getValue(bean);
}
super(scalarDeploy);
this.rootProperty = rootProperty;
this.ctProperty = ctProperty;
this.typeConverter = typeConverter;
}
@Override
public Object elGetReference(EntityBean bean) {
return getValue(bean);
/**
* Return one of the scalar values from a compound type.
*/
public Object getValueObject(Object compoundValue) {
if (typeConverter != null) {
compoundValue = typeConverter.unwrapValue(compoundValue);
}
return ctProperty.getValue(compoundValue);
}
@Override
public Object elGetValue(EntityBean bean) {
return getValue(bean);
@SuppressWarnings("unchecked")
@Override
public Object getValue(EntityBean valueObject) {
Object val = valueObject;
if (typeConverter != null) {
val = typeConverter.unwrapValue(val);
}
return ctProperty.getValue(val);
}
@Override
public void elSetValue(EntityBean bean, Object value, boolean populate) {//, boolean reference) {
super.elSetValue(bean, value, populate);
@Override
public void setValue(EntityBean bean, Object value) {
setValueInCompound(bean, value, false);
}
@SuppressWarnings("unchecked")
public void setValueInCompound(EntityBean bean, Object value, boolean intercept) {
Object compoundValue = ctProperty.setValue(bean, value);
if (compoundValue != null) {
if (typeConverter != null) {
compoundValue = typeConverter.wrapValue(compoundValue);
}
// we are at the top level and we have a compound value
// that we can set using the root property
if (intercept) {
rootProperty.setRootValueIntercept(bean, compoundValue);
} else {
rootProperty.setRootValue(bean, compoundValue);
}
}
}
/**
* No interception on embedded scalar values inside a CVO.
*/
@Override
public void setValueIntercept(EntityBean bean, Object value) {
setValueInCompound(bean, value, true);
}
/**
* No interception on embedded scalar values inside a CVO.
*/
@Override
public Object getValueIntercept(EntityBean bean) {
return getValue(bean);
}
@Override
public Object elGetReference(EntityBean bean) {
return getValue(bean);
}
@Override
public Object elGetValue(EntityBean bean) {
return getValue(bean);
}
@Override
public void elSetValue(EntityBean bean, Object value, boolean populate) {//, boolean reference) {
super.elSetValue(bean, value, populate);
}
}