Package jodd.typeconverter.impl

Examples of jodd.typeconverter.impl.BooleanArrayConverter


    register(short[].class, new ShortArrayConverter(this));
    register(int[].class, new IntegerArrayConverter(this));
    register(long[].class, new LongArrayConverter(this));
    register(float[].class, new FloatArrayConverter(this));
    register(double[].class, new DoubleArrayConverter(this));
    register(boolean[].class, new BooleanArrayConverter(this));
    register(char[].class, new CharacterArrayConverter(this));

    // we don't really need these, but converters will be cached and not created every time
    register(Integer[].class, new ArrayConverter<Integer>(this, Integer.class));
    register(Long[].class, new ArrayConverter<Long>(this, Long.class));
View Full Code Here


public class BooleanArrayConverterTest {

  @Test
  public void testConversion() {
    BooleanArrayConverter booleanArrayConverter = (BooleanArrayConverter) TypeConverterManager.lookup(boolean[].class);

    assertNull(booleanArrayConverter.convert(null));

    boolean[] primitiveArray = new boolean[]{false, true, false};
    Object convertedArray = booleanArrayConverter.convert(primitiveArray);
    assertEquals(boolean[].class, convertedArray.getClass());

    Boolean[] booleanArray = new Boolean[]{Boolean.FALSE, Boolean.TRUE, Boolean.FALSE};
    convertedArray = booleanArrayConverter.convert(booleanArray);
    assertEquals(boolean[].class, convertedArray.getClass());    // boolean[]!

    assertEq(arrl(true), booleanArrayConverter.convert(Boolean.TRUE));
    assertEq(arrl(true), booleanArrayConverter.convert("true"));
    assertEq(arrl(true, false, true), booleanArrayConverter.convert(arrl(true, false, true)));
    assertEq(arrl(true, false, true), booleanArrayConverter.convert(arri(-7, 0, 3)));
    assertEq(arrl(true, false, true), booleanArrayConverter.convert(arrf(-7.0f, 0.0f, 3.0f)));
    assertEq(arrl(true, false, true), booleanArrayConverter.convert(arrs("true", "0", "yes")));
    assertEq(arrl(true, false, true), booleanArrayConverter.convert(arrs(" true ", "0", " yes ")));
    assertEq(arrl(true, false, true), booleanArrayConverter.convert(" true , 0,  yes "));
  }
View Full Code Here

    register(short[].class, new ShortArrayConverter(this));
    register(int[].class, new IntegerArrayConverter(this));
    register(long[].class, new LongArrayConverter(this));
    register(float[].class, new FloatArrayConverter(this));
    register(double[].class, new DoubleArrayConverter(this));
    register(boolean[].class, new BooleanArrayConverter(this));
    register(char[].class, new CharacterArrayConverter(this));

    // we don't really need these, but converters will be cached and not created every time
    register(Integer[].class, new ArrayConverter<Integer>(this, Integer.class) {
      @Override
View Full Code Here

TOP

Related Classes of jodd.typeconverter.impl.BooleanArrayConverter

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.