1 /* 2 * Copyright 2011 Christopher 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.binder; 17 18 import java.lang.annotation.Annotation; 19 20 import org.jadira.bindings.core.api.Binding; 21 import org.jadira.bindings.core.api.Converter; 22 import org.jadira.bindings.core.api.FromUnmarshaller; 23 import org.jadira.bindings.core.api.ToMarshaller; 24 25 public interface SearchableBinder { 26 27 /** 28 * Resolve a Binding with the given source and target class. 29 * A binding unifies a marshaller and an unmarshaller and both must be available to resolve a binding. 30 * 31 * The source class is considered the owning class of the binding. The source can be marshalled 32 * into the target class. Similarly, the target can be unmarshalled to produce an instance of the source type. 33 * @param key The converter key 34 * @param <S> The Source type 35 * @param <T> The Target type 36 * @return The found Binding 37 */ 38 <S, T> Binding<S, T> findBinding(ConverterKey<S,T> key); 39 40 /** 41 * Resolve a Marshaller with the given source and target class. 42 * The marshaller is used as follows: Instances of the source can be marshalled into the target class. 43 * @param key The converter key 44 * @param <S> The Source type 45 * @param <T> The Target type 46 * @return The found Marshaller 47 */ 48 <S, T> ToMarshaller<S, T> findMarshaller(ConverterKey<S,T> key); 49 50 /** 51 * Resolve a Converter with the given input and output classes. Instances of the input class can be converted into 52 * instances of the output class 53 * @param key The converter key 54 * @param <S> The Source type 55 * @param <T> The Target type 56 * @return The found Converter 57 */ 58 <S, T> Converter<S, T> findConverter(ConverterKey<S,T> key); 59 60 /** 61 * Resolve an UnMarshaller with the given source and target class. 62 * The unmarshaller is used as follows: Instances of the source can be marshalled into the target class. 63 * @param key The converter key 64 * @param <S> The Source type 65 * @param <T> The Target type 66 * @return The found Unmarshaller 67 */ 68 <S, T> FromUnmarshaller<S, T> findUnmarshaller(ConverterKey<S,T> key); 69 70 /** 71 * Resolve a Binding with the given source and target class. 72 * A binding unifies a marshaller and an unmarshaller and both must be available to resolve a binding. 73 * <br> 74 * The source class is considered the owning class of the binding. The source can be marshalled 75 * into the target class. Similarly, the target can be unmarshalled to produce an instance of the source type. 76 * @param source The source (owning) class 77 * @param target The target (foreign) class 78 * @param <S> The Source type 79 * @param <T> The Target type 80 * @return The found Binding 81 */ 82 <S, T> Binding<S, T> findBinding(final Class<S> source, final Class<T> target); 83 84 /** 85 * Resolve a Marshaller with the given source and target class. 86 * The marshaller is used as follows: Instances of the source can be marshalled into the target class. 87 * @param source The source (input) class 88 * @param target The target (output) class 89 * @param <S> The Source type 90 * @param <T> The Target type 91 * @return The found Marshaller 92 */ 93 <S, T> ToMarshaller<S, T> findMarshaller(final Class<S> source, final Class<T> target); 94 95 /** 96 * Resolve a Converter with the given input and output classes. Instances of the input class can be converted into 97 * instances of the output class 98 * @param source The input class 99 * @param target The output class 100 * @param <S> The Source type 101 * @param <T> The Target type 102 * @return The found Converter 103 */ 104 <S, T> Converter<S, T> findConverter(final Class<S> source, final Class<T> target); 105 106 /** 107 * Resolve an UnMarshaller with the given source and target class. 108 * The unmarshaller is used as follows: Instances of the source can be marshalled into the target class. 109 * @param source The source (input) class 110 * @param target The target (output) class 111 * @param <S> The Source type 112 * @param <T> The Target type 113 * @return The found Unmarshaller 114 */ 115 <S, T> FromUnmarshaller<S, T> findUnmarshaller(final Class<S> source, final Class<T> target); 116 117 /** 118 * Resolve a Binding with the given source and target class. 119 * A binding unifies a marshaller and an unmarshaller and both must be available to resolve a binding. 120 * <br> 121 * The source class is considered the owning class of the binding. The source can be marshalled 122 * into the target class. Similarly, the target can be unmarshalled to produce an instance of the source type. 123 * @param source The source (owning) class 124 * @param target The target (foreign) class 125 * @param qualifier The qualifier for which the binding must be registered 126 * @param <S> The Source type 127 * @param <T> The Target type 128 * @return The found Binding 129 */ 130 <S, T> Binding<S, T> findBinding(final Class<S> source, final Class<T> target, final Class<? extends Annotation> qualifier); 131 132 /** 133 * Resolve a Marshaller with the given source and target class. 134 * The marshaller is used as follows: Instances of the source can be marshalled into the target class. 135 * @param source The source (input) class 136 * @param target The target (output) class 137 * @param qualifier The qualifier for which the marshaller must be registered 138 * @param <S> The Source type 139 * @param <T> The Target type 140 * @return The found Marshaller 141 */ 142 <S, T> ToMarshaller<S, T> findMarshaller(final Class<S> source, final Class<T> target, final Class<? extends Annotation> qualifier); 143 144 /** 145 * Resolve a Converter with the given input and output classes. Instances of the input class can be converted into 146 * instances of the output class 147 * @param source The input class 148 * @param target The output class 149 * @param qualifier The qualifier for which the marshaller must be registered 150 * @param <S> The Source type 151 * @param <T> The Target type 152 * @return The found Converter 153 */ 154 <S, T> Converter<S, T> findConverter(final Class<S> source, final Class<T> target, final Class<? extends Annotation> qualifier); 155 156 /** 157 * Resolve an UnMarshaller with the given source and target class. 158 * The unmarshaller is used as follows: Instances of the source can be marshalled into the target class. 159 * @param source The source (input) class 160 * @param target The target (output) class 161 * @param qualifier The qualifier for which the unmarshaller must be registered 162 * @param <S> The Source type 163 * @param <T> The Target type 164 * @return The found Unmarshaller 165 */ 166 <S, T> FromUnmarshaller<S, T> findUnmarshaller(final Class<S> source, final Class<T> target, final Class<? extends Annotation> qualifier); 167 }