94 * |
94 * |
95 * @author Attila Szegedi |
95 * @author Attila Szegedi |
96 */ |
96 */ |
97 public interface GuardingTypeConverterFactory { |
97 public interface GuardingTypeConverterFactory { |
98 /** |
98 /** |
99 * Returns a guarded invocation that receives an Object of the specified source type and returns an Object converted |
99 * Returns a guarded type conversion that receives an Object of the specified source type and returns an Object |
100 * to the specified target type. The type of the invocation is targetType(sourceType), while the type of the guard |
100 * converted to the specified target type. The type of the invocation is targetType(sourceType), while the type of |
101 * is boolean(sourceType). Note that this will never be invoked for type conversions allowed by the JLS 5.3 "Method |
101 * the guard is boolean(sourceType). Note that this will never be invoked for type conversions allowed by the JLS |
102 * Invocation Conversion", see {@link TypeUtilities#isMethodInvocationConvertible(Class, Class)} for details. An |
102 * 5.3 "Method Invocation Conversion", see {@link TypeUtilities#isMethodInvocationConvertible(Class, Class)} for |
103 * implementation can assume it is never requested to produce a converter for these conversions. |
103 * details. An implementation can assume it is never requested to produce a converter for these conversions. |
104 * |
104 * |
105 * @param sourceType source type |
105 * @param sourceType source type |
106 * @param targetType the target type. |
106 * @param targetType the target type. |
107 * @return a guarded invocation that can take an object (if it passes guard) and returns another object that is its |
107 * @return a guarded type conversion that contains a guarded invocation that can take an object (if it passes guard) |
108 * representation coerced into the target type. In case the factory is certain it is unable to handle a conversion, |
108 * and return another object that is its representation coerced into the target type. In case the factory is certain |
109 * it can return null. In case the factory is certain that it can always handle the conversion, it can return an |
109 * it is unable to handle a conversion, it can return null. In case the factory is certain that it can always handle |
110 * unconditional invocation (one whose guard is null). |
110 * the conversion, it can return an unconditional invocation (one whose guard is null). |
111 * @throws Exception if there was an error during creation of the converter |
111 * @throws Exception if there was an error during creation of the converter |
112 */ |
112 */ |
113 public GuardedInvocation convertToType(Class<?> sourceType, Class<?> targetType) throws Exception; |
113 public GuardedTypeConversion convertToType(Class<?> sourceType, Class<?> targetType) throws Exception; |
114 } |
114 } |