Package jodd.typeconverter.impl

Examples of jodd.typeconverter.impl.CollectionConverter


    // collection
    if (ReflectUtil.isInterfaceImpl(destinationType, Collection.class)) {
      // component type is unknown because of Java's type-erasure
      CollectionConverter<T> collectionConverter =
          new CollectionConverter(this, destinationType, Object.class);

      return (T) collectionConverter.convert(value);
    }

    // fail
    throw new TypeConversionException("Conversion failed: " + destinationType.getName());
  }
View Full Code Here


    if (componentType == null) {
      componentType = Object.class;
    }

    CollectionConverter collectionConverter = new CollectionConverter(destinationType, componentType);

    return collectionConverter.convert(value);
  }
View Full Code Here

  @Test
  public void testCollectionsWithComponentType() {
    TypeConverterManagerBean tcm = TypeConverterManager.getDefaultTypeConverterManager();

    CollectionConverter cc = new CollectionConverter(tcm, List.class, String.class);
    List<String> list1 = (List<String>) cc.convert(arri(1, 2, 3));
    assertNotEquals(listo(1, 2, 3), list1);
    assertEquals(listo("1", "2", "3"), list1);

    list1 = (List<String>) cc.convert("1,2,3");
    assertEquals(listo("1","2","3"), list1);

    cc = new CollectionConverter(tcm, List.class, Integer.class);
    list1 = (List<String>) cc.convert("1,2,3");
    assertEquals(listo(1, 2, 3), list1);
  }
View Full Code Here

    // collection
    if (ReflectUtil.isTypeOf(destinationType, Collection.class)) {
      // component type is unknown because of Java's type-erasure
      CollectionConverter<T> collectionConverter =
          new CollectionConverter(this, destinationType, Object.class);

      return (T) collectionConverter.convert(value);
    }

    // fail
    throw new TypeConversionException("Conversion failed: " + destinationType.getName());
  }
View Full Code Here

    if (componentType == null) {
      componentType = Object.class;
    }

    CollectionConverter collectionConverter = new CollectionConverter(destinationType, componentType);

    return collectionConverter.convert(value);
  }
View Full Code Here

TOP

Related Classes of jodd.typeconverter.impl.CollectionConverter

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.