Package jodd.typeconverter.impl

Examples of jodd.typeconverter.impl.IntegerConverter


  @SuppressWarnings( {"UnnecessaryFullyQualifiedName"})
  public void registerDefaults() {
    register(String.class, new StringConverter());
    register(String[].class, new StringArrayConverter(this));

    IntegerConverter integerConverter = new IntegerConverter();
    register(Integer.class, integerConverter);
    register(int.class, integerConverter);
    register(MutableInteger.class, new MutableIntegerConverter(this));

    ShortConverter shortConverter = new ShortConverter();
View Full Code Here


public class IntegerConverterTest {

  @Test
  public void testConversion() {
    IntegerConverter integerConverter = new IntegerConverter();

    assertNull(integerConverter.convert(null));

    assertEquals(Integer.valueOf(1), integerConverter.convert(Integer.valueOf(1)));
    assertEquals(Integer.valueOf(1), integerConverter.convert(Short.valueOf((short) 1)));
    assertEquals(Integer.valueOf(1), integerConverter.convert(Double.valueOf(1.0D)));
    assertEquals(Integer.valueOf(1), integerConverter.convert("1"));
    assertEquals(Integer.valueOf(1), integerConverter.convert(" 1 "));

    assertEquals(Integer.valueOf(1), integerConverter.convert(" +1 "));
    assertEquals(Integer.valueOf(-1), integerConverter.convert(" -1 "));
    assertEquals(Integer.valueOf(2147483647), integerConverter.convert(" +2147483647 "));
    assertEquals(Integer.valueOf(-2147483648), integerConverter.convert(" -2147483648 "));

    try {
      assertEquals(Integer.valueOf(1), integerConverter.convert(" 2147483648 "));
      fail();
    } catch (TypeConversionException ignore) {
    }
    try {
      assertEquals(Integer.valueOf(1), integerConverter.convert(" -2147483649 "));
      fail();
    } catch (TypeConversionException ignore) {
    }

    try {
      integerConverter.convert("a");
      fail();
    } catch (TypeConversionException ignore) {
    }
  }
View Full Code Here

  @SuppressWarnings( {"UnnecessaryFullyQualifiedName"})
  public void registerDefaults() {
    register(String.class, new StringConverter());
    register(String[].class, new StringArrayConverter(this));

    IntegerConverter integerConverter = new IntegerConverter();
    register(Integer.class, integerConverter);
    register(int.class, integerConverter);
    register(MutableInteger.class, new MutableIntegerConverter(this));

    ShortConverter shortConverter = new ShortConverter();
View Full Code Here

TOP

Related Classes of jodd.typeconverter.impl.IntegerConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.