Sfoglia il codice sorgente

Remove accidental dependency from new converters to old

Change-Id: I9cd9e691fb30063a914729d15011f5d50e19d8d4
tags/8.0.0.alpha1
Artur Signell 7 anni fa
parent
commit
b565956a51

+ 3
- 7
server/src/main/java/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java Vedi File

@@ -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<T>
* @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<T>
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) {

+ 2
- 5
server/src/main/java/com/vaadin/data/util/converter/Converter.java Vedi File

@@ -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<PRESENTATION, MODEL> extends Serializable {
return new Converter<P, M>() {

@Override
public Result<M> convertToModel(P value, Locale locale)
throws ConversionException {
public Result<M> 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);
}
};

+ 1
- 3
server/src/main/java/com/vaadin/data/util/converter/StringToIntegerConverter.java Vedi File

@@ -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<Integer> convertToModel(String value, Locale locale)
throws ConversionException {
public Result<Integer> convertToModel(String value, Locale locale) {
Number n = convertToNumber(value, locale);

if (n == null) {

Loading…
Annulla
Salva