@@ -112,18 +112,43 @@ object SourceTargetConverter {
112
112
}
113
113
}
114
114
115
- abstract class StrictSourceConverterSkeleton [SS : Type , TT : Type ]extends Converter {
115
+ abstract class StrictSourceConverterSkeleton [SS : Type , TT : Type ] extends Converter {
116
116
final def canConvertType [S : Type , T : Type ]: Boolean = {
117
117
SourceTargetConverter .canConvertWithStrictSource(typeOf[SS ], typeOf[TT ], typeOf[S ], typeOf[T ])
118
118
}
119
119
120
120
final def isStrictSource = true
121
+
122
+ /**
123
+ * Convert or throw an exception.
124
+ *
125
+ * This is a low-level function.
126
+ */
127
+ @ throws(classOf [ConverterException ])
128
+ final def convertEx [T : Type ](sourceValue : Any ) = {
129
+ convertEx_(sourceValue.asInstanceOf [SS ]).asInstanceOf [T ]
130
+ }
131
+
132
+ @ throws(classOf [ConverterException ])
133
+ protected def convertEx_ (sourceValue : SS ): TT
121
134
}
122
135
123
- abstract class NonStrictSourceConverterSkeleton [SS : Type , TT : Type ]extends Converter {
136
+ abstract class NonStrictSourceConverterSkeleton [SS : Type , TT : Type ] extends Converter {
124
137
final def canConvertType [S : Type , T : Type ]: Boolean = {
125
138
SourceTargetConverter .canConvertWithNonStrictSource(typeOf[SS ], typeOf[TT ], typeOf[S ], typeOf[T ])
126
139
}
127
140
128
141
final def isStrictSource = false
142
+
143
+ /**
144
+ * Convert or throw an exception.
145
+ *
146
+ * This is a low-level function.
147
+ */
148
+ final def convertEx [T : Type ](sourceValue : Any ) = {
149
+ convertEx_(sourceValue.asInstanceOf [SS ]).asInstanceOf [T ]
150
+ }
151
+
152
+ protected def convertEx_ (sourceValue : SS ): TT
153
+
129
154
}
0 commit comments