diff options
author | Tobias Holgers <tholgers@users.sourceforge.net> | 2009-04-29 00:48:35 +0000 |
---|---|---|
committer | Tobias Holgers <tholgers@users.sourceforge.net> | 2009-04-29 00:48:35 +0000 |
commit | 4a0115c24f7eb72405ecdc2c2d4cc25af429e5e1 (patch) | |
tree | 0b6c163a2cc82ded85c08eed802245e357d80974 /src/main/java/com/amazon/carbonado/info | |
parent | 8b9ab0b1892477912073c0df7712d9e7520e8983 (diff) |
Added @Derived(shouldCopy=true) to copy derived properties used as repository hints
Diffstat (limited to 'src/main/java/com/amazon/carbonado/info')
-rw-r--r-- | src/main/java/com/amazon/carbonado/info/StorableIntrospector.java | 11 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/info/StorableProperty.java | 10 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java b/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java index 835741b..06218a4 100644 --- a/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java +++ b/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java @@ -85,6 +85,7 @@ import com.amazon.carbonado.util.ThrowUnchecked; *
* @author Brian S O'Neill
* @author Fang Chen
+ * @author Tobias Holgers
*/
public class StorableIntrospector {
// Weakly maps Class objects to softly referenced StorableInfo objects.
@@ -1038,6 +1039,10 @@ public class StorableIntrospector { errorMessages.add("Derived properties cannot be abstract: " +
propertyName);
}
+ if (writeMethod == null && derived.shouldCopy()) {
+ errorMessages.add("Derived properties which should be copied " +
+ "must have a write method: " + propertyName);
+ }
if (pk) {
errorMessages.add("Derived properties cannot be a member of primary key: " +
propertyName);
@@ -1782,6 +1787,7 @@ public class StorableIntrospector { private final boolean mIndependent;
private final boolean mAutomatic;
private final boolean mIsDerived;
+ private final boolean mShouldCopyDerived;
private final String mName;
private final String mBeanName;
@@ -1824,6 +1830,7 @@ public class StorableIntrospector { mIndependent = independent;
mAutomatic = automatic;
mIsDerived = derived != null;
+ mShouldCopyDerived = (mIsDerived ? derived.shouldCopy() : false);
mDerived = derived;
mBeanName = mBeanProperty.getName();
mName = name == null ? mBeanName : name;
@@ -1962,6 +1969,10 @@ public class StorableIntrospector { return mDerivedTo.clone();
}
+ public final boolean shouldCopyDerived() {
+ return mShouldCopyDerived;
+ }
+
public boolean isJoin() {
return false;
}
diff --git a/src/main/java/com/amazon/carbonado/info/StorableProperty.java b/src/main/java/com/amazon/carbonado/info/StorableProperty.java index 36491f8..aadc623 100644 --- a/src/main/java/com/amazon/carbonado/info/StorableProperty.java +++ b/src/main/java/com/amazon/carbonado/info/StorableProperty.java @@ -27,6 +27,7 @@ import com.amazon.carbonado.util.Appender; * Contains all the metadata describing a property of a specific {@link Storable} type.
*
* @author Brian S O'Neill
+ * @author Tobias Holgers
* @see StorableIntrospector
*/
public interface StorableProperty<S extends Storable> extends Serializable, Appender {
@@ -278,5 +279,14 @@ public interface StorableProperty<S extends Storable> extends Serializable, Appe */
ChainedProperty<?>[] getDerivedToProperties();
+ /**
+ * Returns true if this derived property should be included when copying a
+ * storable. Copying of a derived property uses the "get" and "set" methods
+ * and requires the "set" method to be defined.
+ *
+ * @since 1.2
+ */
+ boolean shouldCopyDerived();
+
String toString();
}
|