summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/data/util/MethodProperty.java
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2011-11-08 18:02:55 +0200
committerHenri Sara <hesara@vaadin.com>2011-11-08 18:02:55 +0200
commit0ab1d01c8da1f280370452fa2427708fd6de513e (patch)
tree4bf67b8a478da3b25af35c33c031c837ef2cc2e7 /src/com/vaadin/data/util/MethodProperty.java
parenta61302616430cbbfc97cbdbb85fe294842b3409c (diff)
downloadvaadin-framework-0ab1d01c8da1f280370452fa2427708fd6de513e.tar.gz
vaadin-framework-0ab1d01c8da1f280370452fa2427708fd6de513e.zip
Parameterize Property and Field with the value type.
The interfaces Property and Field and most of their implementations are now parameterized with the type of their value. The method getValue() returns the Property type but setValue() takes Object as its parameter. No implicit conversions between value type and strings are performed in most locations (fields). Among others, AbstractTextField, DateField and RichTextArea not have specific value types and do not accept arbitrary values. Most locations requiring migration will be visible as compilation errors, with the exception of some cases where a non-parameterized Property or Field (or one parametrized with Object) is used. Not yet done: - Label - converters - setValue() parameterization (causes much more migration effort)
Diffstat (limited to 'src/com/vaadin/data/util/MethodProperty.java')
-rw-r--r--src/com/vaadin/data/util/MethodProperty.java14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/com/vaadin/data/util/MethodProperty.java b/src/com/vaadin/data/util/MethodProperty.java
index deb3177094..3809029223 100644
--- a/src/com/vaadin/data/util/MethodProperty.java
+++ b/src/com/vaadin/data/util/MethodProperty.java
@@ -47,7 +47,7 @@ import com.vaadin.util.SerializerHelper;
* @since 3.0
*/
@SuppressWarnings("serial")
-public class MethodProperty<T> extends AbstractProperty {
+public class MethodProperty<T> extends AbstractProperty<T> {
private static final Logger logger = Logger.getLogger(MethodProperty.class
.getName());
@@ -349,7 +349,7 @@ public class MethodProperty<T> extends AbstractProperty {
}
// Tests the parameter types
- final Class[] c = m[i].getParameterTypes();
+ final Class<?>[] c = m[i].getParameterTypes();
if (c.length != getArgs.length) {
// not the right amount of parameters, try next method
@@ -398,7 +398,7 @@ public class MethodProperty<T> extends AbstractProperty {
}
// Checks parameter compatibility
- final Class[] c = m[i].getParameterTypes();
+ final Class<?>[] c = m[i].getParameterTypes();
if (c.length != setArgs.length) {
// not the right amount of parameters, try next method
@@ -569,8 +569,7 @@ public class MethodProperty<T> extends AbstractProperty {
*
* @return type of the Property
*/
- @SuppressWarnings("unchecked")
- public final Class getType() {
+ public final Class<? extends T> getType() {
return type;
}
@@ -593,9 +592,9 @@ public class MethodProperty<T> extends AbstractProperty {
*
* @return the value of the Property
*/
- public Object getValue() {
+ public T getValue() {
try {
- return getMethod.invoke(instance, getArgs);
+ return (T) getMethod.invoke(instance, getArgs);
} catch (final Throwable e) {
throw new MethodException(this, e);
}
@@ -642,7 +641,6 @@ public class MethodProperty<T> extends AbstractProperty {
* native type directly or through <code>String</code>.
* @see #invokeSetMethod(Object)
*/
- @SuppressWarnings("unchecked")
public void setValue(Object newValue) throws Property.ReadOnlyException,
Property.ConversionException {