1 /* 2 * Copyright 2010, 2011 Chris Pheby 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.jadira.bindings.core.spi; 17 18 import java.lang.reflect.Constructor; 19 import java.lang.reflect.Method; 20 import java.util.Map; 21 22 import org.jadira.bindings.core.binder.ConverterKey; 23 24 /** 25 * Defines an extension point to the binding framework for adding new binding capabilities 26 */ 27 public interface ConverterProvider { 28 29 /** 30 * Match methods that can perform a to operation 31 * @param cls The class being inspected 32 * @param <I> Input type 33 * @param <O> Output type 34 * @return The methods 35 */ 36 <I,O> Map<ConverterKey<?, ?>, Method> matchToMethods(Class<?> cls); 37 38 /** 39 * Match constructors that can perform a from operation 40 * @param cls The class being inspected 41 * @param <I> Input type 42 * @param <O> Output type 43 * @return The constructors 44 */ 45 <I,O> Map<ConverterKey<?, ?>, Constructor<O>> matchFromConstructors(Class<O> cls); 46 47 /** 48 * Match methods that can perform a from operation 49 * @param cls The class being inspected 50 * @param <I> Input type 51 * @param <O> Output type 52 * @return The methods 53 */ 54 <I,O> Map<ConverterKey<?, ?>, Method> matchFromMethods(Class<?> cls); 55 }