Java 类org.springframework.core.convert.converter.ConverterFactory 实例源码

项目:spring4-understanding    文件:ConversionServiceFactory.java   
/**
 * Register the given Converter objects with the given target ConverterRegistry.
 * @param converters the converter objects: implementing {@link Converter},
 * {@link ConverterFactory}, or {@link GenericConverter}
 * @param registry the target registry
 */
public static void registerConverters(Set<?> converters, ConverterRegistry registry) {
    if (converters != null) {
        for (Object converter : converters) {
            if (converter instanceof GenericConverter) {
                registry.addConverter((GenericConverter) converter);
            }
            else if (converter instanceof Converter<?, ?>) {
                registry.addConverter((Converter<?, ?>) converter);
            }
            else if (converter instanceof ConverterFactory<?, ?>) {
                registry.addConverterFactory((ConverterFactory<?, ?>) converter);
            }
            else {
                throw new IllegalArgumentException("Each converter object must implement one of the " +
                        "Converter, ConverterFactory, or GenericConverter interfaces");
            }
        }
    }
}
项目:spring    文件:ConversionServiceFactory.java   
/**
 * Register the given Converter objects with the given target ConverterRegistry.
 * @param converters the converter objects: implementing {@link Converter},
 * {@link ConverterFactory}, or {@link GenericConverter}
 * @param registry the target registry
 */
public static void registerConverters(Set<?> converters, ConverterRegistry registry) {
    if (converters != null) {
        for (Object converter : converters) {
            if (converter instanceof GenericConverter) {
                registry.addConverter((GenericConverter) converter);
            }
            else if (converter instanceof Converter<?, ?>) {
                registry.addConverter((Converter<?, ?>) converter);
            }
            else if (converter instanceof ConverterFactory<?, ?>) {
                registry.addConverterFactory((ConverterFactory<?, ?>) converter);
            }
            else {
                throw new IllegalArgumentException("Each converter object must implement one of the " +
                        "Converter, ConverterFactory, or GenericConverter interfaces");
            }
        }
    }
}
项目:dubbox-solr    文件:CustomConversions.java   
/**
 * Register custom converters within given {@link org.springframework.core.convert.support.GenericConversionService}
 *
 * @param conversionService must not be null
 */
public void registerConvertersIn(GenericConversionService conversionService) {
    Assert.notNull(conversionService);

    for (Object converter : converters) {
        if (converter instanceof Converter) {
            conversionService.addConverter((Converter<?, ?>) converter);
        } else if (converter instanceof ConverterFactory) {
            conversionService.addConverterFactory((ConverterFactory<?, ?>) converter);
        } else if (converter instanceof GenericConverter) {
            conversionService.addConverter((GenericConverter) converter);
        } else {
            throw new IllegalArgumentException("Given object '" + converter
                    + "' expected to be a Converter, ConverterFactory or GenericeConverter!");
        }
    }
}
项目:spring-data-crate    文件:CustomConversions.java   
/**
 * Populates the given {@link GenericConversionService} with the converters registered.
 *
 * @param conversionService the service to register.
 */
public void registerConvertersIn(final GenericConversionService conversionService) {
  for (Object converter : converters) {
    boolean added = false;

    if (converter instanceof Converter) {
      conversionService.addConverter((Converter<?, ?>) converter);
      added = true;
    }

    if (converter instanceof ConverterFactory) {
      conversionService.addConverterFactory((ConverterFactory<?, ?>) converter);
      added = true;
    }

    if (converter instanceof GenericConverter) {
      conversionService.addConverter((GenericConverter) converter);
      added = true;
    }

    if (!added) {
      throw new IllegalArgumentException("Given set contains element that is neither Converter nor ConverterFactory!");
    }
  }
}
项目:class-guard    文件:ConversionServiceFactory.java   
/**
 * Register the given Converter objects with the given target ConverterRegistry.
 * @param converters the converter objects: implementing {@link Converter},
 * {@link ConverterFactory}, or {@link GenericConverter}
 * @param registry the target registry
 */
public static void registerConverters(Set<?> converters, ConverterRegistry registry) {
    if (converters != null) {
        for (Object converter : converters) {
            if (converter instanceof GenericConverter) {
                registry.addConverter((GenericConverter) converter);
            }
            else if (converter instanceof Converter<?, ?>) {
                registry.addConverter((Converter<?, ?>) converter);
            }
            else if (converter instanceof ConverterFactory<?, ?>) {
                registry.addConverterFactory((ConverterFactory<?, ?>) converter);
            }
            else {
                throw new IllegalArgumentException("Each converter object must implement one of the " +
                        "Converter, ConverterFactory, or GenericConverter interfaces");
            }
        }
    }
}
项目:spring-data-solr    文件:CustomConversions.java   
/**
 * Register custom converters within given {@link GenericConversionService}
 * 
 * @param conversionService must not be null
 */
public void registerConvertersIn(GenericConversionService conversionService) {
    Assert.notNull(conversionService);

    for (Object converter : converters) {
        if (converter instanceof Converter) {
            conversionService.addConverter((Converter<?, ?>) converter);
        } else if (converter instanceof ConverterFactory) {
            conversionService.addConverterFactory((ConverterFactory<?, ?>) converter);
        } else if (converter instanceof GenericConverter) {
            conversionService.addConverter((GenericConverter) converter);
        } else {
            throw new IllegalArgumentException("Given object '" + converter
                    + "' expected to be a Converter, ConverterFactory or GenericeConverter!");
        }
    }
}
项目:spring-data-tarantool    文件:CustomConversions.java   
/**
 * Populates the given {@link GenericConversionService} with the convertes registered.
 *
 * @param conversionService
 */
public void registerConvertersIn(GenericConversionService conversionService) {

    for (Object converter : converters) {

        boolean added = false;

        if (converter instanceof Converter) {
            conversionService.addConverter((Converter<?, ?>) converter);
            added = true;
        }

        if (converter instanceof ConverterFactory) {
            conversionService.addConverterFactory((ConverterFactory<?, ?>) converter);
            added = true;
        }

        if (converter instanceof GenericConverter) {
            conversionService.addConverter((GenericConverter) converter);
            added = true;
        }

        if (!added) {
            throw new IllegalArgumentException(
                    "Given set contains element that is neither Converter nor ConverterFactory!");
        }
    }
}
项目:spring4-understanding    文件:GenericConversionService.java   
@Override
public void addConverterFactory(ConverterFactory<?, ?> converterFactory) {
    ResolvableType[] typeInfo = getRequiredTypeInfo(converterFactory, ConverterFactory.class);
    Assert.notNull(typeInfo, "Unable to the determine source type <S> and target range type R which your " +
            "ConverterFactory<S, R> converts between; declare these generic types.");
    addConverter(new ConverterFactoryAdapter(converterFactory,
            new ConvertiblePair(typeInfo[0].resolve(), typeInfo[1].resolve())));
}
项目:spring    文件:GenericConversionService.java   
@Override
public void addConverterFactory(ConverterFactory<?, ?> converterFactory) {
    ResolvableType[] typeInfo = getRequiredTypeInfo(converterFactory, ConverterFactory.class);
    Assert.notNull(typeInfo, "Unable to the determine source type <S> and target range type R which your " +
            "ConverterFactory<S, R> converts between; declare these generic types.");
    addConverter(new ConverterFactoryAdapter(converterFactory,
            new ConvertiblePair(typeInfo[0].resolve(), typeInfo[1].resolve())));
}
项目:ubrew_v0.1    文件:ConversionServiceImpl.java   
@Override
public Object postProcessAfterInitialization(Object converter, String beanName) throws BeansException {
    if (converter instanceof GenericConverter) {
        getConversionService().addConverter((GenericConverter) converter);
    } else if (converter instanceof Converter<?, ?>) {
        getConversionService().addConverter((Converter<?, ?>) converter);
    } else if (converter instanceof ConverterFactory<?, ?>) {
        getConversionService().addConverterFactory((ConverterFactory<?, ?>) converter);
    }

    return converter;
}
项目:class-guard    文件:GenericConversionService.java   
public void addConverterFactory(ConverterFactory<?, ?> converterFactory) {
    GenericConverter.ConvertiblePair typeInfo = getRequiredTypeInfo(converterFactory, ConverterFactory.class);
    if (typeInfo == null) {
        throw new IllegalArgumentException("Unable to the determine sourceType <S> and " +
                "targetRangeType R which your ConverterFactory<S, R> converts between; " +
                "declare these generic types.");
    }
    addConverter(new ConverterFactoryAdapter(converterFactory, typeInfo));
}
项目:spring4-understanding    文件:GenericConversionService.java   
public ConverterFactoryAdapter(ConverterFactory<?, ?> converterFactory, ConvertiblePair typeInfo) {
    this.converterFactory = (ConverterFactory<Object, Object>) converterFactory;
    this.typeInfo = typeInfo;
}
项目:spring    文件:GenericConversionService.java   
public ConverterFactoryAdapter(ConverterFactory<?, ?> converterFactory, ConvertiblePair typeInfo) {
    this.converterFactory = (ConverterFactory<Object, Object>) converterFactory;
    this.typeInfo = typeInfo;
}
项目:class-guard    文件:GenericConversionService.java   
public ConverterFactoryAdapter(ConverterFactory<?, ?> converterFactory, ConvertiblePair typeInfo) {
    this.converterFactory = (ConverterFactory<Object, Object>) converterFactory;
    this.typeInfo = typeInfo;
}