From 5403ce66194832e9887cc0d0222ff449464e041f Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Fri, 18 Apr 2008 20:23:47 +0000 Subject: Support renamed properties in indexes and keys. --- src/main/java/com/amazon/carbonado/info/ChainedProperty.java | 5 +---- .../java/com/amazon/carbonado/info/StorableIntrospector.java | 12 +++++++++--- .../java/com/amazon/carbonado/info/StorableProperty.java | 11 ++++++++++- 3 files changed, 20 insertions(+), 8 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/info') diff --git a/src/main/java/com/amazon/carbonado/info/ChainedProperty.java b/src/main/java/com/amazon/carbonado/info/ChainedProperty.java index 65151e8..24a30cf 100644 --- a/src/main/java/com/amazon/carbonado/info/ChainedProperty.java +++ b/src/main/java/com/amazon/carbonado/info/ChainedProperty.java @@ -562,11 +562,8 @@ public class ChainedProperty implements Serializable, Append appendPropTo(app, mPrime.getName(), isOuterJoin(0)); StorableProperty[] chain = mChain; if (chain != null) { - app.append('.'); for (int i=0; i 0) { - app.append('.'); - } + app.append('.'); appendPropTo(app, chain[i].getName(), isOuterJoin(i + 1)); } } diff --git a/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java b/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java index fdfb51f..94b391e 100644 --- a/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java +++ b/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java @@ -624,7 +624,7 @@ public class StorableIntrospector { String sig = createSig(readMethod); if (storableProp.isDerived() || methods.containsKey(sig)) { methods.remove(sig); - properties.put(property.getName(), storableProp); + properties.put(storableProp.getName(), storableProp); } else { continue; } @@ -634,7 +634,7 @@ public class StorableIntrospector { String sig = createSig(writeMethod); if (storableProp.isDerived() || methods.containsKey(sig)) { methods.remove(sig); - properties.put(property.getName(), storableProp); + properties.put(storableProp.getName(), storableProp); } else { continue; } @@ -1594,6 +1594,7 @@ public class StorableIntrospector { private final boolean mAutomatic; private final boolean mIsDerived; private final String mName; + private final String mBeanName; // Temporary reference until derived from is resolved. private Derived mDerived; @@ -1635,13 +1636,18 @@ public class StorableIntrospector { mAutomatic = automatic; mIsDerived = derived != null; mDerived = derived; - mName = name == null ? mBeanProperty.getName() : name; + mBeanName = mBeanProperty.getName(); + mName = name == null ? mBeanName : name; } public final String getName() { return mName; } + public final String getBeanName() { + return mBeanName; + } + public final Class getType() { return mBeanProperty.getType(); } diff --git a/src/main/java/com/amazon/carbonado/info/StorableProperty.java b/src/main/java/com/amazon/carbonado/info/StorableProperty.java index 0d77481..38418ec 100644 --- a/src/main/java/com/amazon/carbonado/info/StorableProperty.java +++ b/src/main/java/com/amazon/carbonado/info/StorableProperty.java @@ -31,10 +31,19 @@ import com.amazon.carbonado.util.Appender; */ public interface StorableProperty extends Serializable, Appender { /** - * Returns the name of this property. + * Returns the name of this property, which is the same as the bean name + * unless it has been {@link com.amazon.carbonado.Name renamed}. */ String getName(); + /** + * Returns the bean name of this property, which is derived from the read + * and write method names. + * + * @since 1.2 + */ + String getBeanName(); + /** * Returns the type of this property. */ -- cgit v1.2.3