From 487a17e439cf7ae75113ef796d8ee22d2a02f547 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sat, 19 Apr 2008 20:59:33 +0000 Subject: Support layout changes when property @Name changes. --- .../carbonado/raw/GenericEncodingStrategy.java | 26 +++++++++++++++++----- .../amazon/carbonado/raw/StorablePropertyInfo.java | 5 +++++ 2 files changed, 25 insertions(+), 6 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/raw') diff --git a/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java b/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java index 7cf3468..edb54d8 100644 --- a/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java +++ b/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java @@ -48,6 +48,7 @@ import com.amazon.carbonado.info.ChainedProperty; import com.amazon.carbonado.info.Direction; import com.amazon.carbonado.info.OrderedProperty; import com.amazon.carbonado.info.StorableIndex; +import com.amazon.carbonado.info.StorableInfo; import com.amazon.carbonado.info.StorableIntrospector; import com.amazon.carbonado.info.StorableProperty; import com.amazon.carbonado.info.StorablePropertyAdapter; @@ -2347,18 +2348,31 @@ public class GenericEncodingStrategy { doDrop: { Class instanceVarClass = instanceVarType.toClass(); if (instanceVarClass != null) { - Map props = - BeanIntrospector.getAllProperties(instanceVarClass); - BeanProperty prop = props.get(info.getPropertyName()); - if (prop != null) { - if (prop.getType() == type.toClass()) { + Class propertyClass; + { + Class inferredType = StorableIntrospector.inferType(instanceVarClass); + if (inferredType != null) { + StorableInfo propInfo = StorableIntrospector.examine(inferredType); + Map props = propInfo.getAllProperties(); + StorableProperty prop = props.get(info.getPropertyName()); + propertyClass = prop == null ? null : prop.getType(); + } else { + Map props = + BeanIntrospector.getAllProperties(instanceVarClass); + BeanProperty prop = props.get(info.getPropertyName()); + propertyClass = prop == null ? null : prop.getType(); + } + } + + if (propertyClass != null) { + if (propertyClass == type.toClass()) { break doDrop; } // Types differ, but if primitive types, perform conversion. TypeDesc primType = type.toPrimitiveType(); if (primType != null) { - TypeDesc propType = TypeDesc.forClass(prop.getType()); + TypeDesc propType = TypeDesc.forClass(propertyClass); TypeDesc primPropType = propType.toPrimitiveType(); if (primPropType != null) { // Apply conversion and store property. diff --git a/src/main/java/com/amazon/carbonado/raw/StorablePropertyInfo.java b/src/main/java/com/amazon/carbonado/raw/StorablePropertyInfo.java index e3a18b1..18db76b 100644 --- a/src/main/java/com/amazon/carbonado/raw/StorablePropertyInfo.java +++ b/src/main/java/com/amazon/carbonado/raw/StorablePropertyInfo.java @@ -129,4 +129,9 @@ public class StorablePropertyInfo implements GenericPropertyInfo { getWriteMethodName(), null, new TypeDesc[] {getPropertyType()}); } } + + @Override + public String toString() { + return mProp.toString(); + } } -- cgit v1.2.3