diff options
Diffstat (limited to 'src/main/java/com/amazon/carbonado/info')
-rw-r--r-- | src/main/java/com/amazon/carbonado/info/StorableIntrospector.java | 24 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/info/StorableProperty.java | 8 |
2 files changed, 29 insertions, 3 deletions
diff --git a/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java b/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java index b7f7744..12fbc01 100644 --- a/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java +++ b/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java @@ -228,9 +228,16 @@ public class StorableIntrospector { // Now that the StorableInfo object has been constructed, assign it
// to all properties to prevent it from being prematurely uncached.
- for (StorableProperty property : properties.values()) {
- if (property instanceof SimpleProperty) {
- ((SimpleProperty)property).setEnclosingInfo(info);
+ // Also assign number now that properties have been sorted.
+ {
+ int number = 0;
+ for (StorableProperty property : properties.values()) {
+ if (property instanceof SimpleProperty) {
+ SimpleProperty sp = (SimpleProperty) property;
+ sp.setEnclosingInfo(info);
+ sp.setNumber(number);
+ }
+ number++;
}
}
@@ -1584,6 +1591,9 @@ public class StorableIntrospector { // Resolved derived to properties.
private ChainedProperty<S>[] mDerivedTo;
+ // Resolved number.
+ private int mNumber = -1;
+
// Reference to enclosing StorableInfo. This reference exists to
// prevent the StorableInfo from being uncached so as long as a
// reference from a property exists.
@@ -1621,6 +1631,10 @@ public class StorableIntrospector { return mBeanProperty.getType();
}
+ public final int getNumber() {
+ return mNumber;
+ }
+
public final Class<S> getEnclosingType() {
return mEnclosingType;
}
@@ -1838,6 +1852,10 @@ public class StorableIntrospector { app.append('}');
}
+ void setNumber(int number) {
+ mNumber = number;
+ }
+
void setEnclosingInfo(StorableInfo<S> info) {
mEnclosingInfo = info;
}
diff --git a/src/main/java/com/amazon/carbonado/info/StorableProperty.java b/src/main/java/com/amazon/carbonado/info/StorableProperty.java index e61c5e9..53b5098 100644 --- a/src/main/java/com/amazon/carbonado/info/StorableProperty.java +++ b/src/main/java/com/amazon/carbonado/info/StorableProperty.java @@ -40,6 +40,14 @@ public interface StorableProperty<S extends Storable> extends Appender { Class<?> getType();
/**
+ * Returns the zero-based numerical position of this property within its
+ * enclosing type.
+ *
+ * @since 1.2
+ */
+ int getNumber();
+
+ /**
* Returns the enclosing type of this property.
*/
Class<S> getEnclosingType();
|