Examples of GenericConversionService


Examples of org.springframework.core.convert.support.GenericConversionService

  @Test
  public void test_binaryPlusWithTimeConverted() {

    final SimpleDateFormat format = new SimpleDateFormat("hh :--: mm :--: ss", Locale.ENGLISH);

    GenericConversionService conversionService = new GenericConversionService();
    conversionService.addConverter(new Converter<Time, String>() {
      @Override
      public String convert(Time source) {
        return format.format(source);
      }
    });
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

   * Create the ConversionService instance returned by this factory bean.
   * <p>Creates a simple {@link GenericConversionService} instance by default.
   * Subclasses may override to customize the ConversionService instance that gets created.
   */
  protected GenericConversionService createConversionService() {
    return new GenericConversionService();
  }
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

  private final SampleBean sample = new SampleBean();

  @Test
  public void customConversion() throws Exception {
    DefaultMessageHandlerMethodFactory instance = createInstance();
    GenericConversionService conversionService = new GenericConversionService();
    conversionService.addConverter(SampleBean.class, String.class, new Converter<SampleBean, String>() {
      @Override
      public String convert(SampleBean source) {
        return "foo bar";
      }
    });
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

  }

  @Test
  public void customConversionServiceFailure() throws Exception {
    DefaultMessageHandlerMethodFactory instance = createInstance();
    GenericConversionService conversionService = new GenericConversionService();
    assertFalse("conversion service should fail to convert payload",
        conversionService.canConvert(Integer.class, String.class));
    instance.setConversionService(conversionService);
    instance.afterPropertiesSet();

    InvocableHandlerMethod invocableHandlerMethod =
        createInvocableHandlerMethod(instance, "simpleString", String.class);
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

  @Override
  protected <E extends GenericEntity<Long, ?>> void doImportItem(
      Map<String, Map<String, GenericEntity<Long, ?>>> idsMapping, Workbook workbook, Class<E> clazz) {
    Sheet sheet = workbook.getSheet(getSheetName(clazz));
    if (sheet != null) {
      GenericConversionService conversionService = getConversionService(workbook, idsMapping);

      Map<String, GenericEntity<Long, ?>> idsMappingForClass = new HashMap<String, GenericEntity<Long, ?>>();
      idsMapping.put(clazz.getName(), idsMappingForClass);

      for (Class<?> referencedClass : getOtherReferencedClasses(clazz)) {
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

    }
  }

  protected GenericConversionService getConversionService(Workbook workbook,
      Map<String, Map<String, GenericEntity<Long, ?>>> idsMapping) {
    GenericConversionService service = new GenericConversionService();

    GenericEntityConverter genericEntityConverter = new GenericEntityConverter(importDataDao, workbook,
        new HashMap<Class<?>, Class<?>>(0), idsMapping);
    genericEntityConverter.setConversionService(service);
    service.addConverter(genericEntityConverter);

    service.addConverter(new ProjectConverter());
    service.addConverter(new ArtifactConverter());
    service.addConverter(new ExternalLinkWrapperConverter());

    DefaultConversionService.addDefaultConverters(service);

    return service;
  }
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

    throw new UnsupportedOperationException();
  }

  private void initBeanWrapper(BeanWrapperImpl beanWrapper) {

    GenericConversionService conversionService = new GenericConversionService();
    conversionService.addConverter(new MultipartFileConverter(beanWrapper));

    beanWrapper.setConversionService(conversionService);
    if (beanFactory != null) {
      beanFactory.copyRegisteredEditorsTo(beanWrapper);
    }
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

  }

  @Test
  public void populatesConversionServiceCorrectly() {

    GenericConversionService conversionService = new DefaultConversionService();

    CustomConversions conversions = new CustomConversions(Arrays.asList(StringToFormatConverter.INSTANCE));
    conversions.registerConvertersIn(conversionService);

    assertThat(conversionService.canConvert(String.class, Format.class), is(true));
  }
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

   */
  @Test
  public void customConverterOverridesDefault() {

    CustomConversions conversions = new CustomConversions(Arrays.asList(CustomDateTimeConverter.INSTANCE));
    GenericConversionService conversionService = new DefaultConversionService();
    conversions.registerConvertersIn(conversionService);

    assertThat(conversionService.convert(new DateTime(), Date.class), is(new Date(0)));
  }
View Full Code Here

Examples of org.springframework.core.convert.support.GenericConversionService

   * Create a new {@link RelaxedConversionService} instance.
   * @param conversionService and option root conversion service
   */
  public RelaxedConversionService(ConversionService conversionService) {
    this.conversionService = conversionService;
    this.additionalConverters = new GenericConversionService();
    this.additionalConverters
        .addConverterFactory(new StringToEnumIgnoringCaseConverterFactory());
    this.additionalConverters.addConverter(new StringToCharArrayConverter());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.