summaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/data/util/converter
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-06-19 16:14:06 +0300
committerArtur Signell <artur@vaadin.com>2012-06-21 17:11:26 +0300
commitd627ad58d2d11a09947a8eac4cd12b72c3d02669 (patch)
treeefbc546a39efdbed49aea70a44d69e32cf07ff2b /src/com/vaadin/data/util/converter
parent71abc602b00089b17b247c64729588a0d187eafd (diff)
downloadvaadin-framework-d627ad58d2d11a09947a8eac4cd12b72c3d02669.tar.gz
vaadin-framework-d627ad58d2d11a09947a8eac4cd12b72c3d02669.zip
Converter support and updated data source logic (#8990, #8991)
Diffstat (limited to 'src/com/vaadin/data/util/converter')
-rw-r--r--src/com/vaadin/data/util/converter/ConverterUtil.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/com/vaadin/data/util/converter/ConverterUtil.java b/src/com/vaadin/data/util/converter/ConverterUtil.java
index 8be8ae799e..5fe3101db2 100644
--- a/src/com/vaadin/data/util/converter/ConverterUtil.java
+++ b/src/com/vaadin/data/util/converter/ConverterUtil.java
@@ -3,11 +3,12 @@
*/
package com.vaadin.data.util.converter;
+import java.io.Serializable;
import java.util.Locale;
import com.vaadin.Application;
-public class ConverterUtil {
+public class ConverterUtil implements Serializable {
public static <UITYPE, MODELTYPE> Converter<UITYPE, MODELTYPE> getConverter(
Class<UITYPE> uiType, Class<MODELTYPE> modelType) {
@@ -110,4 +111,32 @@ public class ConverterUtil {
}
+ /**
+ * Checks if the given converter can handle conversion between the given
+ * presentation and model type
+ *
+ * @param converter
+ * The converter to check
+ * @param presentationType
+ * The presentation type
+ * @param modelType
+ * The model type
+ * @return true if the converter supports conversion between the given
+ * presentation and model type, false otherwise
+ */
+ public static boolean canConverterHandle(Converter<?, ?> converter,
+ Class<?> presentationType, Class<?> modelType) {
+ if (converter == null) {
+ return false;
+ }
+
+ if (!modelType.isAssignableFrom(converter.getModelType())) {
+ return false;
+ }
+ if (!presentationType.isAssignableFrom(converter.getPresentationType())) {
+ return false;
+ }
+
+ return true;
+ }
}