summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/data/Property.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/Property.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/Property.java')
-rw-r--r--src/com/vaadin/data/Property.java24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/com/vaadin/data/Property.java b/src/com/vaadin/data/Property.java
index 3f0da39514..4e711141e8 100644
--- a/src/com/vaadin/data/Property.java
+++ b/src/com/vaadin/data/Property.java
@@ -30,12 +30,15 @@ import java.io.Serializable;
* needs to be changed through the implementing class.
* </p>
*
+ * @param T
+ * type of values of the property
+ *
* @author IT Mill Ltd
* @version
* @VERSION@
* @since 3.0
*/
-public interface Property extends Serializable {
+public interface Property<T> extends Serializable {
/**
* Gets the value stored in the Property. The returned object is compatible
@@ -43,7 +46,7 @@ public interface Property extends Serializable {
*
* @return the value stored in the Property
*/
- public Object getValue();
+ public T getValue();
/**
* Sets the value of the Property.
@@ -52,26 +55,19 @@ public interface Property extends Serializable {
* missing, one should declare the Property to be in read-only mode and
* throw <code>Property.ReadOnlyException</code> in this function.
* </p>
- * Note : It is not required, but highly recommended to support setting the
- * value also as a <code>String</code> in addition to the native type of the
- * Property (as given by the <code>getType</code> method). If the
- * <code>String</code> conversion fails or is unsupported, the method should
- * throw <code>Property.ConversionException</code>. The string conversion
- * should at least understand the format returned by the
- * <code>toString</code> method of the Property.
*
- * TODO correct this comment as eliminating Property.toString()
+ * Note : Since Vaadin 7.0, setting the value of a non-String property as a
+ * String is no longer supported.
*
* @param newValue
* New value of the Property. This should be assignable to the
- * type returned by getType, but also String type should be
- * supported
+ * type returned by getType
*
* @throws Property.ReadOnlyException
* if the object is in read-only mode
* @throws Property.ConversionException
* if newValue can't be converted into the Property's native
- * type directly or through String
+ * type directly or using a converter
*/
public void setValue(Object newValue) throws Property.ReadOnlyException,
Property.ConversionException;
@@ -85,7 +81,7 @@ public interface Property extends Serializable {
*
* @return type of the Property
*/
- public Class<?> getType();
+ public Class<? extends T> getType();
/**
* Tests if the Property is in read-only mode. In read-only mode calls to