Package jodd.typeconverter.impl

Examples of jodd.typeconverter.impl.ShortConverter


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

    ShortConverter shortConverter = new ShortConverter();
    register(Short.class, shortConverter);
    register(short.class, shortConverter);
    register(MutableShort.class, new MutableShortConverter(this));

    LongConverter longConverter = new LongConverter();
View Full Code Here


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

    ShortConverter shortConverter = new ShortConverter();
    register(Short.class, shortConverter);
    register(short.class, shortConverter);
    register(MutableShort.class, new MutableShortConverter(this));

    LongConverter longConverter = new LongConverter();
View Full Code Here

public class ShortConverterTest {

  @Test
  public void testConversion() {
    ShortConverter shortConverter = new ShortConverter();

    assertNull(shortConverter.convert(null));

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

    assertEquals(Short.valueOf((short) 1), shortConverter.convert(" +1 "));
    assertEquals(Short.valueOf((short) -1), shortConverter.convert(" -1 "));
    assertEquals(Short.valueOf((short) 32767), shortConverter.convert(" +32767 "));
    assertEquals(Short.valueOf((short) -32768), shortConverter.convert(" -32768 "));

    try {
      shortConverter.convert("a");
      fail();
    } catch (TypeConversionException ignore) {
    }
    try {
      shortConverter.convert("+32768");
      fail();
    } catch (TypeConversionException ignore) {
    }
    try {
      shortConverter.convert("-32769");
      fail();
    } catch (TypeConversionException ignore) {
    }
  }
View Full Code Here

TOP

Related Classes of jodd.typeconverter.impl.ShortConverter

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.