Author: simoneg
Date: Tue Jun 7 16:49:47 2011
New Revision: 1133095
URL: http://svn.apache.org/viewvc?rev=1133095&view=rev
Log:
Better access to underlying property, with easier support for ITDs and other
aspects
Modified:
labs/magma/trunk/foundation-beans/src/main/java/org/apache/magma/beans/PropertyInfo.java
Modified:
labs/magma/trunk/foundation-beans/src/main/java/org/apache/magma/beans/PropertyInfo.java
URL:
http://svn.apache.org/viewvc/labs/magma/trunk/foundation-beans/src/main/java/org/apache/magma/beans/PropertyInfo.java?rev=1133095&r1=1133094&r2=1133095&view=diff
==============================================================================
---
labs/magma/trunk/foundation-beans/src/main/java/org/apache/magma/beans/PropertyInfo.java
(original)
+++
labs/magma/trunk/foundation-beans/src/main/java/org/apache/magma/beans/PropertyInfo.java
Tue Jun 7 16:49:47 2011
@@ -141,7 +141,7 @@ public class PropertyInfo implements Clo
*/
private boolean isUnderlying = false;
-
+ private PropertyDescriptor descriptor = null;
private Method readMethod;
private Method writeMethod;
@@ -199,7 +199,10 @@ public class PropertyInfo implements Clo
public boolean isEnum() {
return this.isEnum;
}
-
+
+ public void init(PropertyDescriptor descriptor, Class beanClass) {
+ this.init(descriptor, beanClass, false);
+ }
/**
* Initializes this class, parsing the {@link PropertyDescriptor} and
eventually annotations found on the getter or setter methods.
*
@@ -209,7 +212,9 @@ public class PropertyInfo implements Clo
* @param beanClass the class of the bean containing the property.
*/
@SuppressWarnings("unchecked")
- public void init(PropertyDescriptor descriptor, Class beanClass) {
+ public void init(PropertyDescriptor descriptor, Class beanClass,
boolean underlying) {
+ this.isUnderlying = underlying;
+ this.descriptor = descriptor;
this.beanClass = beanClass;
this.name = descriptor.getName();
readMethod = descriptor.getReadMethod();
@@ -218,7 +223,7 @@ public class PropertyInfo implements Clo
Consider consider = null;
if (readMethod != null) consider =
readMethod.getAnnotation(Consider.class);
if (consider == null && writeMethod != null) consider =
writeMethod.getAnnotation(Consider.class);
- if (consider != null) {
+ if (consider != null && !underlying) {
this.underlyingType = descriptor.getPropertyType();
this.type = consider.value();
this.underlyingConverter =
Converters.getConverterFor(this.type, this.underlyingType);
@@ -252,15 +257,14 @@ public class PropertyInfo implements Clo
this.readable = readMethod != null;
this.writeable = writeMethod != null;
this.underlyingWriteable = this.writeable;
- if ((readMethod != null &&
readMethod.isAnnotationPresent(MagReadOnly.class)) ||
- (writeMethod != null &&
writeMethod.isAnnotationPresent(MagReadOnly.class)) ||
-
beanClass.isAnnotationPresent(MagReadOnly.class)) {
- this.writeable = false;
+ if (!underlying) {
+ if ((readMethod != null &&
readMethod.isAnnotationPresent(MagReadOnly.class)) ||
+ (writeMethod != null &&
writeMethod.isAnnotationPresent(MagReadOnly.class)) ||
+
beanClass.isAnnotationPresent(MagReadOnly.class)) {
+ this.writeable = false;
+ }
}
- initType();
- }
-
- private void initType() {
+
if (this.type != null) {
this.isCollection =
Collection.class.isAssignableFrom(this.type);
this.isMap = Map.class.isAssignableFrom(this.type);
@@ -299,13 +303,7 @@ public class PropertyInfo implements Clo
}
protected void initAsUnderlying(PropertyInfo sup) {
- this.isUnderlying = true;
- this.name = sup.name;
- this.beanClass = sup.beanClass;
- this.readable = sup.readable;
- this.type = sup.underlyingType;
- this.writeable = sup.underlyingWriteable;
- this.initType();
+ this.init(sup.descriptor, sup.beanClass, true);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]