當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultConversionService.addConverter方法代碼示例

本文整理匯總了Java中org.springframework.core.convert.support.DefaultConversionService.addConverter方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultConversionService.addConverter方法的具體用法?Java DefaultConversionService.addConverter怎麽用?Java DefaultConversionService.addConverter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.core.convert.support.DefaultConversionService的用法示例。


在下文中一共展示了DefaultConversionService.addConverter方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDefaultConversionService

import org.springframework.core.convert.support.DefaultConversionService; //導入方法依賴的package包/類
/**
 * Initialize default ConversionService
 *
 * @return
 */
private ConfigurableConversionService getDefaultConversionService() {
    if (this.defaultConversionService == null) {
        DefaultConversionService conversionService = new DefaultConversionService();
        this.applicationContext.getAutowireCapableBeanFactory().autowireBean(this);
        for (Converter<?, ?> converter : this.converters) {
            conversionService.addConverter(converter);
        }
        for (GenericConverter genericConverter : this.genericConverters) {
            conversionService.addConverter(genericConverter);
        }
        this.defaultConversionService = conversionService;
    }
    return this.defaultConversionService;
}
 
開發者ID:zouzhirong,項目名稱:configx,代碼行數:20,代碼來源:ConfigPropertyResolver.java

示例2: getDefaultConversionService

import org.springframework.core.convert.support.DefaultConversionService; //導入方法依賴的package包/類
private ConversionService getDefaultConversionService() {
	if (this.defaultConversionService == null) {
		DefaultConversionService conversionService = new DefaultConversionService();
		this.applicationContext.getAutowireCapableBeanFactory().autowireBean(this);
		for (Converter<?, ?> converter : this.converters) {
			conversionService.addConverter(converter);
		}
		for (GenericConverter genericConverter : this.genericConverters) {
			conversionService.addConverter(genericConverter);
		}
		this.defaultConversionService = conversionService;
	}
	return this.defaultConversionService;
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:15,代碼來源:ConfigurationPropertiesBindingPostProcessor.java

示例3: mongoStoreConverter

import org.springframework.core.convert.support.DefaultConversionService; //導入方法依賴的package包/類
@Bean
public DefaultConversionService mongoStoreConverter() {
	DefaultConversionService conversion = new DefaultConversionService();
	if (customConverters != null) {
		for (Converter<?,String> converter : customConverters) {
			conversion.addConverter(converter);
		}
	}
	return conversion;
}
 
開發者ID:paulcwarren,項目名稱:spring-content,代碼行數:11,代碼來源:MongoStoreConfiguration.java

示例4: testDelegatingConversion

import org.springframework.core.convert.support.DefaultConversionService; //導入方法依賴的package包/類
@Test
public void testDelegatingConversion() {
	DefaultConversionService conversionService = new DefaultConversionService();
	GenericMapConverter mapConverter = new GenericMapConverter(conversionService);
	conversionService.addConverter(mapConverter);

	TypeDescriptor targetType = TypeDescriptor.map(Map.class, TypeDescriptor.valueOf(Charset.class),
			TypeDescriptor.valueOf(UUID.class));
	@SuppressWarnings("unchecked")
	Map<Charset, UUID> result = (Map<Charset, UUID>) conversionService
			.convert("UTF-8 = c46c18c7-b000-44d0-8326-f12ddf423972", targetType);

	assertThat(result, hasEntry(Charset.forName("UTF-8"), UUID.fromString("c46c18c7-b000-44d0-8326-f12ddf423972")));
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-stream-app-starters,代碼行數:15,代碼來源:GenericMapConverterTests.java

示例5: testEscapes

import org.springframework.core.convert.support.DefaultConversionService; //導入方法依賴的package包/類
@Test
public void testEscapes() {
	DefaultConversionService conversionService = new DefaultConversionService();
	GenericMapConverter mapConverter = new GenericMapConverter(conversionService);
	conversionService.addConverter(mapConverter);

	TypeDescriptor targetType = TypeDescriptor.map(Map.class, TypeDescriptor.valueOf(String.class),
			TypeDescriptor.valueOf(String[].class));
	@SuppressWarnings("unchecked")
	Map<String, String[]> result = (Map<String, String[]>) conversionService.convert("foo = bar\\,quizz",
			targetType);

	assertThat(result.values().iterator().next(), Matchers.arrayContaining("bar", "quizz"));

}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-stream-app-starters,代碼行數:16,代碼來源:GenericMapConverterTests.java

示例6: defaultCamelConversionService

import org.springframework.core.convert.support.DefaultConversionService; //導入方法依賴的package包/類
@ConditionalOnMissingBean
@Bean
ConversionService defaultCamelConversionService(ApplicationContext applicationContext) {
    DefaultConversionService service = new DefaultConversionService();
    for (Converter converter : applicationContext.getBeansOfType(Converter.class).values()) {
        service.addConverter(converter);
    }
    return service;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:10,代碼來源:TypeConversionConfiguration.java

示例7: getDefaultConversionService

import org.springframework.core.convert.support.DefaultConversionService; //導入方法依賴的package包/類
private ConversionService getDefaultConversionService() {
	if (this.defaultConversionService == null) {
		DefaultConversionService conversionService = new DefaultConversionService();
		this.applicationContext.getAutowireCapableBeanFactory().autowireBean(this);
		for (Converter<?, ?> converter : this.converters) {
			conversionService.addConverter(converter);
		}
		this.defaultConversionService = conversionService;
	}
	return this.defaultConversionService;
}
 
開發者ID:Nephilim84,項目名稱:contestparser,代碼行數:12,代碼來源:ConfigurationPropertiesBindingPostProcessor.java

示例8: conversionService

import org.springframework.core.convert.support.DefaultConversionService; //導入方法依賴的package包/類
@Bean
public ConversionService conversionService()
{
	DefaultConversionService defaultConversionService = new DefaultConversionService();
	defaultConversionService.addConverter(new StringToDateConverter());
	defaultConversionService.addConverter(new StringToDateTimeConverter());
	return defaultConversionService;
}
 
開發者ID:molgenis,項目名稱:molgenis,代碼行數:9,代碼來源:PlatformITConfig.java


注:本文中的org.springframework.core.convert.support.DefaultConversionService.addConverter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。