From b565956a51e870287fb01ea9365ce947e33641f5 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 18 Aug 2016 22:38:21 +0300 Subject: [PATCH] Remove accidental dependency from new converters to old Change-Id: I9cd9e691fb30063a914729d15011f5d50e19d8d4 --- .../converter/AbstractStringToNumberConverter.java | 10 +++------- .../java/com/vaadin/data/util/converter/Converter.java | 7 ++----- .../data/util/converter/StringToIntegerConverter.java | 4 +--- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/server/src/main/java/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java b/server/src/main/java/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java index 1dbc2bf46a..bd2ea690a1 100644 --- a/server/src/main/java/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java +++ b/server/src/main/java/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java @@ -20,8 +20,6 @@ import java.text.NumberFormat; import java.text.ParsePosition; import java.util.Locale; -import com.vaadin.v7.data.util.converter.LegacyConverter.ConversionException; - /** * A converter that converts from the number type T to {@link String} and back. * Uses the given locale and {@link NumberFormat} for formatting and parsing. @@ -62,11 +60,8 @@ public abstract class AbstractStringToNumberConverter * @param locale * The locale to use for conversion * @return The converted value - * @throws ConversionException - * If there was a problem converting the value */ - protected Number convertToNumber(String value, Locale locale) - throws ConversionException { + protected Number convertToNumber(String value, Locale locale) { if (value == null) { return null; } @@ -79,7 +74,8 @@ public abstract class AbstractStringToNumberConverter ParsePosition parsePosition = new ParsePosition(0); Number parsedValue = getFormat(locale).parse(value, parsePosition); if (parsePosition.getIndex() != value.length()) { - throw new ConversionException("Could not convert '" + value + "'"); + throw new IllegalArgumentException( + "Could not convert '" + value + "'"); } if (parsedValue == null) { diff --git a/server/src/main/java/com/vaadin/data/util/converter/Converter.java b/server/src/main/java/com/vaadin/data/util/converter/Converter.java index 4ccafc5384..345f8df5bf 100644 --- a/server/src/main/java/com/vaadin/data/util/converter/Converter.java +++ b/server/src/main/java/com/vaadin/data/util/converter/Converter.java @@ -21,7 +21,6 @@ import java.util.Locale; import java.util.function.Function; import com.vaadin.data.Binder.Binding; -import com.vaadin.v7.data.util.converter.LegacyConverter.ConversionException; import com.vaadin.data.Result; /** @@ -125,14 +124,12 @@ public interface Converter extends Serializable { return new Converter() { @Override - public Result convertToModel(P value, Locale locale) - throws ConversionException { + public Result convertToModel(P value, Locale locale) { return toModel.apply(value); } @Override - public P convertToPresentation(M value, Locale locale) - throws ConversionException { + public P convertToPresentation(M value, Locale locale) { return toPresentation.apply(value); } }; diff --git a/server/src/main/java/com/vaadin/data/util/converter/StringToIntegerConverter.java b/server/src/main/java/com/vaadin/data/util/converter/StringToIntegerConverter.java index ba7531a4d6..16dcd832dd 100644 --- a/server/src/main/java/com/vaadin/data/util/converter/StringToIntegerConverter.java +++ b/server/src/main/java/com/vaadin/data/util/converter/StringToIntegerConverter.java @@ -20,7 +20,6 @@ import java.text.NumberFormat; import java.util.Locale; import com.vaadin.data.Result; -import com.vaadin.v7.data.util.converter.LegacyConverter.ConversionException; /** * A converter that converts from {@link String} to {@link Integer} and back. @@ -66,8 +65,7 @@ public class StringToIntegerConverter } @Override - public Result convertToModel(String value, Locale locale) - throws ConversionException { + public Result convertToModel(String value, Locale locale) { Number n = convertToNumber(value, locale); if (n == null) { -- 2.39.5