]> source.dussan.org Git - vaadin-framework.git/commitdiff
Throw exception from Property.toString() implementations.
authorHenri Sara <hesara@vaadin.com>
Mon, 7 Nov 2011 15:56:31 +0000 (17:56 +0200)
committerHenri Sara <hesara@vaadin.com>
Mon, 7 Nov 2011 15:56:31 +0000 (17:56 +0200)
The default implementations of Property.toString() now throw an
UnsupportedOperationException to help find and eliminate code relying on
Property.toString().

src/com/vaadin/data/util/AbstractProperty.java
src/com/vaadin/data/util/IndexedContainer.java
src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java
src/com/vaadin/ui/AbstractField.java
src/com/vaadin/ui/Label.java
src/com/vaadin/ui/ProgressIndicator.java

index 0b943e5eae6f090db5e4c3b3b86c3a11e5d4fa39..2297f13734a8ad2489b882d360bbc6adaba3f7e7 100644 (file)
@@ -66,7 +66,9 @@ public abstract class AbstractProperty implements Property,
     @Deprecated
     @Override
     public String toString() {
-        return getStringValue();
+        throw new UnsupportedOperationException(
+                "Use Property.getValue() instead of " + getClass()
+                        + ".toString()");
     }
 
     /**
index 67bb4f0ddeb394c6301f1df0ad8cb701f8319db8..c9499d4aa8287ba43a391cb17671f3832a3182cb 100644 (file)
@@ -917,7 +917,8 @@ public class IndexedContainer extends
         @Deprecated
         @Override
         public String toString() {
-            return getStringValue();
+            throw new UnsupportedOperationException(
+                    "Use Property.getValue() instead of IndexedContainerProperty.toString()");
         }
 
         /**
index 32cc9d09d4b20bca339da40a358b2a1afddaa045..c1474fc7605e3f6b1787807cb475fe587bdd2913 100644 (file)
@@ -178,7 +178,8 @@ final public class ColumnProperty implements Property {
     @Deprecated
     @Override
     public String toString() {
-        return getStringValue();
+        throw new UnsupportedOperationException(
+                "Use ColumnProperty.getValue() instead of ColumnProperty.toString()");
     }
 
     /**
index 8754d3cd5366effeadfa9d68e7ceca227d9790f1..007f851a722936aaf865f5dbc358ba900f3ed0e8 100644 (file)
@@ -410,7 +410,9 @@ public abstract class AbstractField extends AbstractComponent implements Field,
     @Deprecated
     @Override
     public String toString() {
-        return getStringValue();
+        throw new UnsupportedOperationException(
+                "Use Property.getValue() instead of " + getClass()
+                        + ".toString()");
     }
 
     /**
index 5a82b6424386f04f65e79d08fb647f982d63998b..c7504230e37d573e0b5c74eda09834f44bf6504e 100644 (file)
@@ -252,7 +252,8 @@ public class Label extends AbstractComponent implements Property,
     @Deprecated
     @Override
     public String toString() {
-        return getStringValue();
+        throw new UnsupportedOperationException(
+                "Use Property.getValue() instead of Label.toString()");
     }
 
     /**
index 88e0edcd025c79db01ea12f6a51cfc4fb47761d0..6f2758f323d3ee437cd8576889d6b922a612bc66 100644 (file)
@@ -155,11 +155,8 @@ public class ProgressIndicator extends AbstractField implements Property,
     @Deprecated
     @Override
     public String toString() {
-        if (dataSource == null) {
-            throw new IllegalStateException("Datasource must be set");
-        }
-        Object value = dataSource.getValue();
-        return (null != value) ? value.toString() : null;
+        throw new UnsupportedOperationException(
+                "Use Property.getValue() instead of ProgressIndicator.toString()");
     }
 
     /**