001/*
002 * Copyright 2002-2016 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.core.convert.converter;
018
019/**
020 * For registering converters with a type conversion system.
021 *
022 * @author Keith Donald
023 * @author Juergen Hoeller
024 * @since 3.0
025 */
026public interface ConverterRegistry {
027
028        /**
029         * Add a plain converter to this registry.
030         * The convertible source/target type pair is derived from the Converter's parameterized types.
031         * @throws IllegalArgumentException if the parameterized types could not be resolved
032         */
033        void addConverter(Converter<?, ?> converter);
034
035        /**
036         * Add a plain converter to this registry.
037         * The convertible source/target type pair is specified explicitly.
038         * <p>Allows for a Converter to be reused for multiple distinct pairs without
039         * having to create a Converter class for each pair.
040         * @since 3.1
041         */
042        <S, T> void addConverter(Class<S> sourceType, Class<T> targetType, Converter<? super S, ? extends T> converter);
043
044        /**
045         * Add a generic converter to this registry.
046         */
047        void addConverter(GenericConverter converter);
048
049        /**
050         * Add a ranged converter factory to this registry.
051         * The convertible source/target type pair is derived from the ConverterFactory's parameterized types.
052         * @throws IllegalArgumentException if the parameterized types could not be resolved
053         */
054        void addConverterFactory(ConverterFactory<?, ?> factory);
055
056        /**
057         * Remove any converters from {@code sourceType} to {@code targetType}.
058         * @param sourceType the source type
059         * @param targetType the target type
060         */
061        void removeConvertible(Class<?> sourceType, Class<?> targetType);
062
063}