001/*
002 *  Copyright 2010, 2011 Chris Pheby
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 *      http://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 */
016package org.jadira.bindings.core.spi;
017
018import java.lang.reflect.Constructor;
019import java.lang.reflect.Method;
020import java.util.Map;
021
022import org.jadira.bindings.core.binder.ConverterKey;
023
024/**
025 * Defines an extension point to the binding framework for adding new binding capabilities
026 */
027public interface ConverterProvider {
028    
029    /**
030     * Match methods that can perform a to operation
031     * @param cls The class being inspected
032         * @param <I> Input type
033         * @param <O> Output  type
034     * @return The methods
035     */
036        <I,O> Map<ConverterKey<?, ?>, Method> matchToMethods(Class<?> cls);
037 
038    /**
039     * Match constructors that can perform a from operation
040     * @param cls The class being inspected
041         * @param <I> Input type
042         * @param <O> Output  type
043     * @return The constructors
044     */
045    <I,O> Map<ConverterKey<?, ?>, Constructor<O>> matchFromConstructors(Class<O> cls);
046    
047    /**
048     * Match methods that can perform a from operation
049     * @param cls The class being inspected
050         * @param <I> Input type
051         * @param <O> Output  type
052     * @return The methods
053     */
054    <I,O> Map<ConverterKey<?, ?>, Method> matchFromMethods(Class<?> cls);
055}