On 20 October 2013 21:28,  <ohe...@apache.org> wrote:
> Author: oheger
> Date: Sun Oct 20 20:28:19 2013
> New Revision: 1533967
>
> URL: http://svn.apache.org/r1533967
> Log:
> Generified all number converters.
>
> Modified:
>     
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java
>     
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java
>     
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/ByteConverter.java
>     
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/DoubleConverter.java
>     
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/FloatConverter.java
>     
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/IntegerConverter.java
>     
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/LongConverter.java
>     
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/NumberConverter.java
>     
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/ShortConverter.java
>     
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/BigDecimalConverterTestCase.java
>     
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/BigIntegerConverterTestCase.java
>     
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/ByteConverterTestCase.java
>     
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/DoubleConverterTestCase.java
>     
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/FloatConverterTestCase.java
>     
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/IntegerConverterTestCase.java
>     
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/LongConverterTestCase.java
>     
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/NumberConverterTestBase.java
>     
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/ShortConverterTestCase.java
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java
>  Sun Oct 20 20:28:19 2013
> @@ -33,7 +33,7 @@ import java.math.BigDecimal;
>   * @version $Id$
>   * @since 1.3
>   */
> -public final class BigDecimalConverter extends NumberConverter {
> +public final class BigDecimalConverter extends NumberConverter<BigDecimal> {
>
>      /**
>       * Construct a <b>java.math.BigDecimal</b> <i>Converter</i> that throws
> @@ -62,7 +62,7 @@ public final class BigDecimalConverter e
>       * @since 1.8.0
>       */
>      @Override
> -    protected Class getDefaultType() {
> +    protected Class<BigDecimal> getDefaultType() {
>          return BigDecimal.class;

Won't that change the method signature?

AIUI, the erasure will now be BigDecimal rather than Object.

This needs checking.

>      }
>
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java
>  Sun Oct 20 20:28:19 2013
> @@ -33,7 +33,7 @@ import java.math.BigInteger;
>   * @version $Id$
>   * @since 1.3
>   */
> -public final class BigIntegerConverter extends NumberConverter {
> +public final class BigIntegerConverter extends NumberConverter<BigInteger> {
>
>      /**
>       * Construct a <b>java.math.BigInteger</b> <i>Converter</i> that throws
> @@ -62,7 +62,7 @@ public final class BigIntegerConverter e
>       * @since 1.8.0
>       */
>      @Override
> -    protected Class getDefaultType() {
> +    protected Class<BigInteger> getDefaultType() {
>          return BigInteger.class;
>      }
>
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/ByteConverter.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/ByteConverter.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/ByteConverter.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/ByteConverter.java
>  Sun Oct 20 20:28:19 2013
> @@ -31,7 +31,7 @@ package org.apache.commons.beanutils.con
>   * @version $Id$
>   * @since 1.3
>   */
> -public final class ByteConverter extends NumberConverter {
> +public final class ByteConverter extends NumberConverter<Byte> {
>
>      /**
>       * Construct a <b>java.lang.Byte</b> <i>Converter</i> that throws
> @@ -60,7 +60,7 @@ public final class ByteConverter extends
>       * @since 1.8.0
>       */
>      @Override
> -    protected Class getDefaultType() {
> +    protected Class<Byte> getDefaultType() {
>          return Byte.class;
>      }
>
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/DoubleConverter.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/DoubleConverter.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/DoubleConverter.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/DoubleConverter.java
>  Sun Oct 20 20:28:19 2013
> @@ -31,7 +31,7 @@ package org.apache.commons.beanutils.con
>   * @version $Id$
>   * @since 1.3
>   */
> -public final class DoubleConverter extends NumberConverter {
> +public final class DoubleConverter extends NumberConverter<Double> {
>
>      /**
>       * Construct a <b>java.lang.Double</b> <i>Converter</i> that throws
> @@ -60,7 +60,7 @@ public final class DoubleConverter exten
>       * @since 1.8.0
>       */
>      @Override
> -    protected Class getDefaultType() {
> +    protected Class<Double> getDefaultType() {
>          return Double.class;
>      }
>
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/FloatConverter.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/FloatConverter.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/FloatConverter.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/FloatConverter.java
>  Sun Oct 20 20:28:19 2013
> @@ -31,7 +31,7 @@ package org.apache.commons.beanutils.con
>   * @version $Id$
>   * @since 1.3
>   */
> -public final class FloatConverter extends NumberConverter {
> +public final class FloatConverter extends NumberConverter<Float> {
>
>      /**
>       * Construct a <b>java.lang.Float</b> <i>Converter</i> that throws
> @@ -60,7 +60,7 @@ public final class FloatConverter extend
>       * @since 1.8.0
>       */
>      @Override
> -    protected Class getDefaultType() {
> +    protected Class<Float> getDefaultType() {
>          return Float.class;
>      }
>
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/IntegerConverter.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/IntegerConverter.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/IntegerConverter.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/IntegerConverter.java
>  Sun Oct 20 20:28:19 2013
> @@ -31,7 +31,7 @@ package org.apache.commons.beanutils.con
>   * @version $Id$
>   * @since 1.3
>   */
> -public final class IntegerConverter extends NumberConverter {
> +public final class IntegerConverter extends NumberConverter<Integer> {
>
>      /**
>       * Construct a <b>java.lang.Integer</b> <i>Converter</i> that throws
> @@ -60,7 +60,7 @@ public final class IntegerConverter exte
>       * @since 1.8.0
>       */
>      @Override
> -    protected Class getDefaultType() {
> +    protected Class<Integer> getDefaultType() {
>          return Integer.class;
>      }
>
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/LongConverter.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/LongConverter.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/LongConverter.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/LongConverter.java
>  Sun Oct 20 20:28:19 2013
> @@ -31,7 +31,7 @@ package org.apache.commons.beanutils.con
>   * @version $Id$
>   * @since 1.3
>   */
> -public final class LongConverter extends NumberConverter {
> +public final class LongConverter extends NumberConverter<Long> {
>
>      /**
>       * Construct a <b>java.lang.Long</b> <i>Converter</i> that throws
> @@ -60,7 +60,7 @@ public final class LongConverter extends
>       * @since 1.8.0
>       */
>      @Override
> -    protected Class getDefaultType() {
> +    protected Class<Long> getDefaultType() {
>          return Long.class;
>      }
>
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/NumberConverter.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/NumberConverter.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/NumberConverter.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/NumberConverter.java
>  Sun Oct 20 20:28:19 2013
> @@ -16,15 +16,15 @@
>   */
>  package org.apache.commons.beanutils.converters;
>
> -import java.util.Calendar;
> -import java.util.Date;
> -import java.util.Locale;
>  import java.math.BigDecimal;
>  import java.math.BigInteger;
> -import java.text.NumberFormat;
>  import java.text.DecimalFormat;
>  import java.text.DecimalFormatSymbols;
> +import java.text.NumberFormat;
>  import java.text.ParsePosition;
> +import java.util.Calendar;
> +import java.util.Date;
> +import java.util.Locale;
>
>  import org.apache.commons.beanutils.ConversionException;
>
> @@ -79,10 +79,11 @@ import org.apache.commons.beanutils.Conv
>   * For example to cater for number styles used in Germany such as 
> <code>0.000,00</code> the pattern
>   * is specified in the normal form <code>0,000.00</code> and the locale set 
> to <code>Locale.GERMANY</code>.
>   *
> + * @param <D> the default type of this converter
>   * @version $Id$
>   * @since 1.8.0
>   */
> -public abstract class NumberConverter extends AbstractConverter {
> +public abstract class NumberConverter<D> extends AbstractConverter<D> {
>
>      private static final Integer ZERO = new Integer(0);
>      private static final Integer ONE  = new Integer(1);
> @@ -229,9 +230,9 @@ public abstract class NumberConverter ex
>       * @throws Throwable if an error occurs converting to the specified type
>       */
>      @Override
> -    protected Object convertToType(Class targetType, Object value) throws 
> Throwable {
> +    protected <T> T convertToType(Class<T> targetType, Object value) throws 
> Throwable {
>
> -        Class sourceType = value.getClass();
> +        Class<?> sourceType = value.getClass();
>          // Handle Number
>          if (value instanceof Number) {
>              return toNumber(sourceType, targetType, (Number)value);
> @@ -244,12 +245,12 @@ public abstract class NumberConverter ex
>
>          // Handle Date --> Long
>          if (value instanceof Date && Long.class.equals(targetType)) {
> -            return new Long(((Date)value).getTime());
> +            return targetType.cast(new Long(((Date)value).getTime()));
>          }
>
>          // Handle Calendar --> Long
>          if (value instanceof Calendar  && Long.class.equals(targetType)) {
> -            return new Long(((Calendar)value).getTime().getTime());
> +            return targetType.cast(new 
> Long(((Calendar)value).getTime().getTime()));
>          }
>
>          // Convert all other types to String & handle
> @@ -296,11 +297,11 @@ public abstract class NumberConverter ex
>       *
>       * @return The converted value.
>       */
> -    private Number toNumber(Class sourceType, Class targetType, Number 
> value) {
> +    private <T> T toNumber(Class<?> sourceType, Class<T> targetType, Number 
> value) {
>
>          // Correct Number type already
>          if (targetType.equals(value.getClass())) {
> -            return value;
> +            return targetType.cast(value);
>          }
>
>          // Byte
> @@ -314,7 +315,7 @@ public abstract class NumberConverter ex
>                  throw new ConversionException(toString(sourceType) + " value 
> '" + value
>                          + "' is too small " + toString(targetType));
>              }
> -            return new Byte(value.byteValue());
> +            return targetType.cast(new Byte(value.byteValue()));
>          }
>
>          // Short
> @@ -328,7 +329,7 @@ public abstract class NumberConverter ex
>                  throw new ConversionException(toString(sourceType) + " value 
> '" + value
>                          + "' is too small " + toString(targetType));
>              }
> -            return new Short(value.shortValue());
> +            return targetType.cast(new Short(value.shortValue()));
>          }
>
>          // Integer
> @@ -342,12 +343,12 @@ public abstract class NumberConverter ex
>                  throw new ConversionException(toString(sourceType) + " value 
> '" + value
>                          + "' is too small " + toString(targetType));
>              }
> -            return new Integer(value.intValue());
> +            return targetType.cast(new Integer(value.intValue()));
>          }
>
>          // Long
>          if (targetType.equals(Long.class)) {
> -            return new Long(value.longValue());
> +            return targetType.cast(new Long(value.longValue()));
>          }
>
>          // Float
> @@ -356,31 +357,31 @@ public abstract class NumberConverter ex
>                  throw new ConversionException(toString(sourceType) + " value 
> '" + value
>                          + "' is too large for " + toString(targetType));
>              }
> -            return new Float(value.floatValue());
> +            return targetType.cast(new Float(value.floatValue()));
>          }
>
>          // Double
>          if (targetType.equals(Double.class)) {
> -            return new Double(value.doubleValue());
> +            return targetType.cast(new Double(value.doubleValue()));
>          }
>
>          // BigDecimal
>          if (targetType.equals(BigDecimal.class)) {
>              if (value instanceof Float || value instanceof Double) {
> -                return new BigDecimal(value.toString());
> +                return targetType.cast(new BigDecimal(value.toString()));
>              } else if (value instanceof BigInteger) {
> -                return new BigDecimal((BigInteger)value);
> +                return targetType.cast(new BigDecimal((BigInteger)value));
>              } else {
> -                return BigDecimal.valueOf(value.longValue());
> +                return 
> targetType.cast(BigDecimal.valueOf(value.longValue()));
>              }
>          }
>
>          // BigInteger
>          if (targetType.equals(BigInteger.class)) {
>              if (value instanceof BigDecimal) {
> -                return ((BigDecimal)value).toBigInteger();
> +                return targetType.cast(((BigDecimal)value).toBigInteger());
>              } else {
> -                return BigInteger.valueOf(value.longValue());
> +                return 
> targetType.cast(BigInteger.valueOf(value.longValue()));
>              }
>          }
>
> @@ -413,7 +414,7 @@ public abstract class NumberConverter ex
>       *
>       * @return The converted Number value.
>       */
> -    private Number toNumber(Class sourceType, Class targetType, String 
> value) {
> +    private Number toNumber(Class<?> sourceType, Class<?> targetType, String 
> value) {
>
>          // Byte
>          if (targetType.equals(Byte.class)) {
> @@ -530,7 +531,7 @@ public abstract class NumberConverter ex
>
>      /**
>       * Convert a String into a <code>Number</code> object.
> -     * @param sourceType TODO
> +     * @param sourceType the source type of the conversion
>       * @param targetType The type to convert the value to
>       * @param value The String date value.
>       * @param format The NumberFormat to parse the String value.
> @@ -538,7 +539,7 @@ public abstract class NumberConverter ex
>       * @return The converted Number object.
>       * @throws ConversionException if the String cannot be converted.
>       */
> -    private Number parse(Class sourceType, Class targetType, String value, 
> NumberFormat format) {
> +    private Number parse(Class<?> sourceType, Class<?> targetType, String 
> value, NumberFormat format) {
>          ParsePosition pos = new ParsePosition(0);
>          Number parsedNumber = format.parse(value, pos);
>          if (pos.getErrorIndex() >= 0 || pos.getIndex() != value.length() || 
> parsedNumber == null) {
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/ShortConverter.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/ShortConverter.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/ShortConverter.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/converters/ShortConverter.java
>  Sun Oct 20 20:28:19 2013
> @@ -31,7 +31,7 @@ package org.apache.commons.beanutils.con
>   * @version $Id$
>   * @since 1.3
>   */
> -public final class ShortConverter extends NumberConverter {
> +public final class ShortConverter extends NumberConverter<Short> {
>
>      /**
>       * Construct a <b>java.lang.Short</b> <i>Converter</i> that throws
> @@ -60,7 +60,7 @@ public final class ShortConverter extend
>       * @since 1.8.0
>       */
>      @Override
> -    protected Class getDefaultType() {
> +    protected Class<Short> getDefaultType() {
>          return Short.class;
>      }
>
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/BigDecimalConverterTestCase.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/BigDecimalConverterTestCase.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/BigDecimalConverterTestCase.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/BigDecimalConverterTestCase.java
>  Sun Oct 20 20:28:19 2013
> @@ -63,17 +63,17 @@ public class BigDecimalConverterTestCase
>      // 
> ------------------------------------------------------------------------
>
>      @Override
> -    protected NumberConverter makeConverter() {
> +    protected NumberConverter<?> makeConverter() {
>          return new BigDecimalConverter();
>      }
>
>      @Override
> -    protected NumberConverter makeConverter(Object defaultValue) {
> +    protected NumberConverter<?> makeConverter(Object defaultValue) {
>          return new BigDecimalConverter(defaultValue);
>      }
>
>      @Override
> -    protected Class getExpectedType() {
> +    protected Class<?> getExpectedType() {
>          return BigDecimal.class;
>      }
>
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/BigIntegerConverterTestCase.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/BigIntegerConverterTestCase.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/BigIntegerConverterTestCase.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/BigIntegerConverterTestCase.java
>  Sun Oct 20 20:28:19 2013
> @@ -62,17 +62,17 @@ public class BigIntegerConverterTestCase
>      // 
> ------------------------------------------------------------------------
>
>      @Override
> -    protected NumberConverter makeConverter() {
> +    protected NumberConverter<?> makeConverter() {
>          return new BigIntegerConverter();
>      }
>
>      @Override
> -    protected NumberConverter makeConverter(Object defaultValue) {
> +    protected NumberConverter<?> makeConverter(Object defaultValue) {
>          return new BigIntegerConverter(defaultValue);
>      }
>
>      @Override
> -    protected Class getExpectedType() {
> +    protected Class<?> getExpectedType() {
>          return BigInteger.class;
>      }
>
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/ByteConverterTestCase.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/ByteConverterTestCase.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/ByteConverterTestCase.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/ByteConverterTestCase.java
>  Sun Oct 20 20:28:19 2013
> @@ -61,16 +61,16 @@ public class ByteConverterTestCase exten
>      // 
> ------------------------------------------------------------------------
>
>      @Override
> -    protected NumberConverter makeConverter() {
> +    protected NumberConverter<?> makeConverter() {
>          return new ByteConverter();
>      }
>
>      @Override
> -    protected NumberConverter makeConverter(Object defaultValue) {
> +    protected NumberConverter<?> makeConverter(Object defaultValue) {
>          return new ByteConverter(defaultValue);
>      }
>      @Override
> -    protected Class getExpectedType() {
> +    protected Class<?> getExpectedType() {
>          return Byte.class;
>      }
>
> @@ -137,7 +137,7 @@ public class ByteConverterTestCase exten
>       */
>      public void testInvalidAmount() {
>          Converter converter = makeConverter();
> -        Class clazz = Byte.class;
> +        Class<?> clazz = Byte.class;
>
>          Long min         = new Long(Byte.MIN_VALUE);
>          Long max         = new Long(Byte.MAX_VALUE);
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/DoubleConverterTestCase.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/DoubleConverterTestCase.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/DoubleConverterTestCase.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/DoubleConverterTestCase.java
>  Sun Oct 20 20:28:19 2013
> @@ -61,17 +61,17 @@ public class DoubleConverterTestCase ext
>      // 
> ------------------------------------------------------------------------
>
>      @Override
> -    protected NumberConverter makeConverter() {
> +    protected NumberConverter<?> makeConverter() {
>          return new DoubleConverter();
>      }
>
>      @Override
> -    protected NumberConverter makeConverter(Object defaultValue) {
> +    protected NumberConverter<?> makeConverter(Object defaultValue) {
>          return new DoubleConverter(defaultValue);
>      }
>
>      @Override
> -    protected Class getExpectedType() {
> +    protected Class<?> getExpectedType() {
>          return Double.class;
>      }
>
> @@ -130,12 +130,12 @@ public class DoubleConverterTestCase ext
>              assertEquals(
>                  message[i] + " to Double",
>                  expected[i].doubleValue(),
> -                
> ((Double)(converter.convert(Double.class,input[i]))).doubleValue(),
> +                (converter.convert(Double.class,input[i])).doubleValue(),
>                  0.00001D);
>              assertEquals(
>                  message[i] + " to double",
>                  expected[i].doubleValue(),
> -                
> ((Double)(converter.convert(Double.TYPE,input[i]))).doubleValue(),
> +                (converter.convert(Double.TYPE,input[i])).doubleValue(),
>                  0.00001D);
>              assertEquals(
>                  message[i] + " to null type",
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/FloatConverterTestCase.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/FloatConverterTestCase.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/FloatConverterTestCase.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/FloatConverterTestCase.java
>  Sun Oct 20 20:28:19 2013
> @@ -61,17 +61,17 @@ public class FloatConverterTestCase exte
>      // 
> ------------------------------------------------------------------------
>
>      @Override
> -    protected NumberConverter makeConverter() {
> +    protected NumberConverter<?> makeConverter() {
>          return new FloatConverter();
>      }
>
>      @Override
> -    protected NumberConverter makeConverter(Object defaultValue) {
> +    protected NumberConverter<?> makeConverter(Object defaultValue) {
>          return new FloatConverter(defaultValue);
>      }
>
>      @Override
> -    protected Class getExpectedType() {
> +    protected Class<?> getExpectedType() {
>          return Float.class;
>      }
>
> @@ -130,12 +130,12 @@ public class FloatConverterTestCase exte
>              assertEquals(
>                  message[i] + " to Float",
>                  expected[i].floatValue(),
> -                
> ((Float)(converter.convert(Float.class,input[i]))).floatValue(),
> +                (converter.convert(Float.class,input[i])).floatValue(),
>                  0.00001);
>              assertEquals(
>                  message[i] + " to float",
>                  expected[i].floatValue(),
> -                
> ((Float)(converter.convert(Float.TYPE,input[i]))).floatValue(),
> +                (converter.convert(Float.TYPE,input[i])).floatValue(),
>                  0.00001);
>              assertEquals(
>                  message[i] + " to null type",
> @@ -151,7 +151,7 @@ public class FloatConverterTestCase exte
>       */
>      public void testInvalidAmount() {
>          Converter converter = makeConverter();
> -        Class clazz = Float.class;
> +        Class<?> clazz = Float.class;
>
>          Double max     = new Double(Float.MAX_VALUE);
>          Double tooBig  = new Double(Double.MAX_VALUE);
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/IntegerConverterTestCase.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/IntegerConverterTestCase.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/IntegerConverterTestCase.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/IntegerConverterTestCase.java
>  Sun Oct 20 20:28:19 2013
> @@ -19,6 +19,7 @@ package org.apache.commons.beanutils.con
>
>  import junit.framework.TestSuite;
>
> +import org.apache.commons.beanutils.ConversionException;
>  import org.apache.commons.beanutils.Converter;
>
>
> @@ -61,17 +62,17 @@ public class IntegerConverterTestCase ex
>      // 
> ------------------------------------------------------------------------
>
>      @Override
> -    protected NumberConverter makeConverter() {
> +    protected NumberConverter<?> makeConverter() {
>          return new IntegerConverter();
>      }
>
>      @Override
> -    protected NumberConverter makeConverter(Object defaultValue) {
> +    protected NumberConverter<?> makeConverter(Object defaultValue) {
>          return new IntegerConverter(defaultValue);
>      }
>
>      @Override
> -    protected Class getExpectedType() {
> +    protected Class<?> getExpectedType() {
>          return Integer.class;
>      }
>
> @@ -138,7 +139,7 @@ public class IntegerConverterTestCase ex
>       */
>      public void testInvalidAmount() {
>          Converter converter = makeConverter();
> -        Class clazz = Integer.class;
> +        Class<?> clazz = Integer.class;
>
>          Long min         = new Long(Integer.MIN_VALUE);
>          Long max         = new Long(Integer.MAX_VALUE);
> @@ -167,5 +168,18 @@ public class IntegerConverterTestCase ex
>              // expected result
>          }
>      }
> +
> +    /**
> +     * Tests whether an invalid default object causes an exception.
> +     */
> +    public void testInvalidDefaultObject() {
> +        NumberConverter<?> converter = makeConverter();
> +        try {
> +            converter.setDefaultValue("notANumber");
> +            fail("Invalid default value not detected!");
> +        } catch (ConversionException cex) {
> +            // expected result
> +        }
> +    }
>  }
>
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/LongConverterTestCase.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/LongConverterTestCase.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/LongConverterTestCase.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/LongConverterTestCase.java
>  Sun Oct 20 20:28:19 2013
> @@ -61,17 +61,17 @@ public class LongConverterTestCase exten
>      // 
> ------------------------------------------------------------------------
>
>      @Override
> -    protected NumberConverter makeConverter() {
> +    protected NumberConverter<?> makeConverter() {
>          return new LongConverter();
>      }
>
>      @Override
> -    protected NumberConverter makeConverter(Object defaultValue) {
> +    protected NumberConverter<?> makeConverter(Object defaultValue) {
>          return new LongConverter(defaultValue);
>      }
>
>      @Override
> -    protected Class getExpectedType() {
> +    protected Class<?> getExpectedType() {
>          return Long.class;
>      }
>
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/NumberConverterTestBase.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/NumberConverterTestBase.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/NumberConverterTestBase.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/NumberConverterTestBase.java
>  Sun Oct 20 20:28:19 2013
> @@ -47,9 +47,9 @@ public abstract class NumberConverterTes
>
>      // 
> ------------------------------------------------------------------------
>
> -    protected abstract NumberConverter makeConverter();
> -    protected abstract NumberConverter makeConverter(Object defaultValue);
> -    protected abstract Class getExpectedType();
> +    protected abstract NumberConverter<?> makeConverter();
> +    protected abstract NumberConverter<?> makeConverter(Object defaultValue);
> +    protected abstract Class<?> getExpectedType();
>
>      // 
> ------------------------------------------------------------------------
>
> @@ -111,7 +111,7 @@ public abstract class NumberConverterTes
>          Locale defaultLocale = Locale.getDefault();
>          Locale.setDefault(Locale.US);
>
> -        NumberConverter converter = makeConverter();
> +        NumberConverter<?> converter = makeConverter();
>          converter.setPattern("[0,0.0];(0,0.0)");
>
>          // Default Locale
> @@ -136,7 +136,7 @@ public abstract class NumberConverterTes
>          Locale defaultLocale = Locale.getDefault();
>          Locale.setDefault(Locale.US);
>
> -        NumberConverter converter = makeConverter();
> +        NumberConverter<?> converter = makeConverter();
>          converter.setUseLocaleFormat(true);
>
>          // Default Locale
> @@ -158,7 +158,7 @@ public abstract class NumberConverterTes
>      public void testStringArrayToInteger() {
>
>          Integer defaultValue = new Integer(-1);
> -        NumberConverter converter = makeConverter(defaultValue);
> +        NumberConverter<?> converter = makeConverter(defaultValue);
>
>          // Default Locale
>          assertEquals("Valid First",   new Integer(5), 
> converter.convert(Integer.class, new String[] {"5", "4", "3"}));
> @@ -172,7 +172,7 @@ public abstract class NumberConverterTes
>       */
>      public void testNumberToStringDefault() {
>
> -        NumberConverter converter = makeConverter();
> +        NumberConverter<?> converter = makeConverter();
>
>          // Default Number --> String conversion
>          assertEquals("Default Convert " + numbers[0], numbers[0].toString(), 
> converter.convert(String.class, numbers[0]));
> @@ -189,7 +189,7 @@ public abstract class NumberConverterTes
>          Locale defaultLocale = Locale.getDefault();
>          Locale.setDefault(Locale.US);
>
> -        NumberConverter converter = makeConverter();
> +        NumberConverter<?> converter = makeConverter();
>          converter.setPattern("[0,0];(0,0)");
>
>          // Default Locale
> @@ -236,7 +236,7 @@ public abstract class NumberConverterTes
>          Locale defaultLocale = Locale.getDefault();
>          Locale.setDefault(Locale.US);
>
> -        NumberConverter converter = makeConverter();
> +        NumberConverter<?> converter = makeConverter();
>          converter.setUseLocaleFormat(true);
>
>          // Default Locale
> @@ -273,7 +273,7 @@ public abstract class NumberConverterTes
>       */
>      public void testStringToNumberDefault() {
>
> -        NumberConverter converter = makeConverter();
> +        NumberConverter<?> converter = makeConverter();
>          converter.setUseLocaleFormat(false);
>
>          // Default String --> Number conversion
> @@ -289,11 +289,22 @@ public abstract class NumberConverterTes
>      }
>
>      /**
> +     * Convert String --> Number if the target type is not defined. Then the
> +     * default type should be used.
> +     */
> +    public void testStringToNumberDefaultType() {
> +        NumberConverter<?> converter = makeConverter();
> +        converter.setUseLocaleFormat(false);
> +
> +        assertEquals("Default Convert " + numbers[0], numbers[0], 
> converter.convert(null, numbers[0].toString()));
> +    }
> +
> +    /**
>       * Convert Boolean --> Number (default conversion)
>       */
>      public void testBooleanToNumberDefault() {
>
> -        NumberConverter converter = makeConverter();
> +        NumberConverter<?> converter = makeConverter();
>
>          // Other type --> String conversion
>          assertEquals("Boolean.FALSE to Number ", 0, 
> ((Number)converter.convert(getExpectedType(), Boolean.FALSE)).intValue());
> @@ -306,7 +317,7 @@ public abstract class NumberConverterTes
>       */
>      public void testDateToNumber() {
>
> -        NumberConverter converter = makeConverter();
> +        NumberConverter<?> converter = makeConverter();
>
>          Date dateValue = new Date();
>          long longValue = dateValue.getTime();
> @@ -329,7 +340,7 @@ public abstract class NumberConverterTes
>       */
>      public void testCalendarToNumber() {
>
> -        NumberConverter converter = makeConverter();
> +        NumberConverter<?> converter = makeConverter();
>
>          Calendar calendarValue = Calendar.getInstance();
>          long longValue = calendarValue.getTime().getTime();
> @@ -352,7 +363,7 @@ public abstract class NumberConverterTes
>       */
>      public void testOtherToStringDefault() {
>
> -        NumberConverter converter = makeConverter();
> +        NumberConverter<?> converter = makeConverter();
>
>          // Other type --> String conversion
>          assertEquals("Default Convert ", "ABC", 
> converter.convert(String.class, new StringBuffer("ABC")));
> @@ -365,7 +376,7 @@ public abstract class NumberConverterTes
>      public void testInvalidDefault() {
>
>          Object defaultvalue = numbers[0];
> -        NumberConverter converter = makeConverter(defaultvalue);
> +        NumberConverter<?> converter = makeConverter(defaultvalue);
>
>          // Default String --> Number conversion
>          assertEquals("Invalid null ", defaultvalue, 
> converter.convert(getExpectedType(), null));
> @@ -377,7 +388,7 @@ public abstract class NumberConverterTes
>       */
>      public void testInvalidException() {
>
> -        NumberConverter converter = makeConverter();
> +        NumberConverter<?> converter = makeConverter();
>
>          try {
>              converter.convert(getExpectedType(), null);
> @@ -398,7 +409,7 @@ public abstract class NumberConverterTes
>       */
>      public void testInvalidType() {
>
> -        NumberConverter converter = makeConverter();
> +        NumberConverter<?> converter = makeConverter();
>
>          try {
>              converter.convert(Object.class, numbers[0]);
> @@ -407,5 +418,21 @@ public abstract class NumberConverterTes
>              // expected result
>          }
>      }
> +
> +    /**
> +     * Tests a conversion to an unsupported type if a default value is set.
> +     */
> +    public void testInvalidTypeWithDefault() {
> +
> +        NumberConverter<?> converter = makeConverter(42);
> +
> +        try {
> +            converter.convert(Object.class, numbers[0]);
> +            fail("Invalid type with default test, expected 
> ConversionException");
> +        } catch(ConversionException e) {
> +            // expected result
> +        }
> +    }
> +
>  }
>
>
> Modified: 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/ShortConverterTestCase.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/ShortConverterTestCase.java?rev=1533967&r1=1533966&r2=1533967&view=diff
> ==============================================================================
> --- 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/ShortConverterTestCase.java
>  (original)
> +++ 
> commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/converters/ShortConverterTestCase.java
>  Sun Oct 20 20:28:19 2013
> @@ -61,17 +61,17 @@ public class ShortConverterTestCase exte
>      // 
> ------------------------------------------------------------------------
>
>      @Override
> -    protected NumberConverter makeConverter() {
> +    protected NumberConverter<?> makeConverter() {
>          return new ShortConverter();
>      }
>
>      @Override
> -    protected NumberConverter makeConverter(Object defaultValue) {
> +    protected NumberConverter<?> makeConverter(Object defaultValue) {
>          return new ShortConverter(defaultValue);
>      }
>
>      @Override
> -    protected Class getExpectedType() {
> +    protected Class<?> getExpectedType() {
>          return Short.class;
>      }
>
> @@ -138,7 +138,7 @@ public class ShortConverterTestCase exte
>       */
>      public void testInvalidAmount() {
>          Converter converter = makeConverter();
> -        Class clazz = Short.class;
> +        Class<?> clazz = Short.class;
>
>          Long min         = new Long(Short.MIN_VALUE);
>          Long max         = new Long(Short.MAX_VALUE);
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to