ConverterRegistry's addConverter declares generic type variables
Issue: SPR-12948
This commit is contained in:
parent
d18b3f049a
commit
8a69159004
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -27,18 +27,19 @@ public interface ConverterRegistry {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a plain converter to this registry.
|
* Add a plain converter to this registry.
|
||||||
* The convertible sourceType/targetType pair is derived from the Converter's parameterized types.
|
* The convertible source/target type pair is derived from the Converter's parameterized types.
|
||||||
* @throws IllegalArgumentException if the parameterized types could not be resolved
|
* @throws IllegalArgumentException if the parameterized types could not be resolved
|
||||||
*/
|
*/
|
||||||
void addConverter(Converter<?, ?> converter);
|
void addConverter(Converter<?, ?> converter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a plain converter to this registry.
|
* Add a plain converter to this registry.
|
||||||
* The convertible sourceType/targetType pair is specified explicitly.
|
* The convertible source/target type pair is specified explicitly.
|
||||||
* Allows for a Converter to be reused for multiple distinct pairs without having to create a Converter class for each pair.
|
* <p>Allows for a Converter to be reused for multiple distinct pairs without
|
||||||
|
* having to create a Converter class for each pair.
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
void addConverter(Class<?> sourceType, Class<?> targetType, Converter<?, ?> converter);
|
<S, T> void addConverter(Class<S> sourceType, Class<T> targetType, Converter<? super S, ? extends T> converter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a generic converter to this registry.
|
* Add a generic converter to this registry.
|
||||||
|
|
@ -47,7 +48,7 @@ public interface ConverterRegistry {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a ranged converter factory to this registry.
|
* Add a ranged converter factory to this registry.
|
||||||
* The convertible sourceType/rangeType pair is derived from the ConverterFactory's parameterized types.
|
* The convertible source/target type pair is derived from the ConverterFactory's parameterized types.
|
||||||
* @throws IllegalArgumentException if the parameterized types could not be resolved.
|
* @throws IllegalArgumentException if the parameterized types could not be resolved.
|
||||||
*/
|
*/
|
||||||
void addConverterFactory(ConverterFactory<?, ?> converterFactory);
|
void addConverterFactory(ConverterFactory<?, ?> converterFactory);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -141,8 +141,7 @@ public class DefaultConversionService extends GenericConversionService {
|
||||||
converterRegistry.addConverter(Boolean.class, String.class, new ObjectToStringConverter());
|
converterRegistry.addConverter(Boolean.class, String.class, new ObjectToStringConverter());
|
||||||
|
|
||||||
converterRegistry.addConverterFactory(new StringToEnumConverterFactory());
|
converterRegistry.addConverterFactory(new StringToEnumConverterFactory());
|
||||||
converterRegistry.addConverter(Enum.class, String.class,
|
converterRegistry.addConverter(new EnumToStringConverter((ConversionService) converterRegistry));
|
||||||
new EnumToStringConverter((ConversionService) converterRegistry));
|
|
||||||
|
|
||||||
converterRegistry.addConverter(new StringToLocaleConverter());
|
converterRegistry.addConverter(new StringToLocaleConverter());
|
||||||
converterRegistry.addConverter(Locale.class, String.class, new ObjectToStringConverter());
|
converterRegistry.addConverter(Locale.class, String.class, new ObjectToStringConverter());
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -103,7 +103,7 @@ public class GenericConversionService implements ConfigurableConversionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addConverter(Class<?> sourceType, Class<?> targetType, Converter<?, ?> converter) {
|
public <S, T> void addConverter(Class<S> sourceType, Class<T> targetType, Converter<? super S, ? extends T> converter) {
|
||||||
addConverter(new ConverterAdapter(
|
addConverter(new ConverterAdapter(
|
||||||
converter, ResolvableType.forClass(sourceType), ResolvableType.forClass(targetType)));
|
converter, ResolvableType.forClass(sourceType), ResolvableType.forClass(targetType)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue