@@ -27,29 +27,29 @@ import com.ckkloverdos.maybe.MaybeEither
27
27
trait ConverterBase {
28
28
protected val logger = LoggerFactory .getLogger(getClass)
29
29
30
- def canConvertValueToType [S : Type , T : Type ](sourceValue : S ): Boolean =
31
- canConvertType[S , T ]
30
+ def canConvertValueToType [S : Type , T : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Boolean =
31
+ canConvertType[S , T ](hint)
32
32
33
- def canConvertValueToValue [S : Type , T : Type ](sourceValue : S , targetValue : T ): Boolean =
34
- canConvertType[S , T ]
33
+ def canConvertValueToValue [S : Type , T : Type ](sourceValue : S , targetValue : T , hint : AnyRef = EmptyHint ): Boolean =
34
+ canConvertType[S , T ](hint)
35
35
36
- def canConvertType [S : Type , T : Type ]: Boolean
36
+ def canConvertType [S : Type , T : Type ]( hint : AnyRef = EmptyHint ) : Boolean
37
37
38
38
/**
39
39
* Convert or throw an exception.
40
40
*
41
41
* This is a low-level function.
42
42
*/
43
43
@ throws(classOf [ConverterException ])
44
- def convertEx [T : Type ](sourceValue : Any ): T
44
+ def convertEx [T : Type ](sourceValue : Any , hint : AnyRef = EmptyHint ): T
45
45
46
- def convert [T : Type ](sourceValue : Any ): MaybeEither [T ] = MaybeEither {
46
+ def convert [T : Type ](sourceValue : Any , hint : AnyRef = EmptyHint ): MaybeEither [T ] = MaybeEither {
47
47
// logger.debug("ConverterBase::convert(%s: %s): %s".format(sourceValue, sourceValue.getClass, manifest[T]))
48
- convertEx[T ](sourceValue)
48
+ convertEx[T ](sourceValue, hint )
49
49
}
50
50
51
- def convertOpt [T : Type ](sourceValue : Any ): Option [T ] = {
52
- try Some (convertEx[T ](sourceValue))
51
+ def convertOpt [T : Type ](sourceValue : Any , hint : AnyRef = EmptyHint ): Option [T ] = {
52
+ try Some (convertEx[T ](sourceValue, hint ))
53
53
catch {
54
54
case e : Error ⇒
55
55
throw e
@@ -59,51 +59,51 @@ trait ConverterBase {
59
59
}
60
60
}
61
61
62
- def convertToByte [S : Type ](sourceValue : S ): MaybeEither [Byte ] = convert[Byte ](sourceValue)
62
+ def convertToByte [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): MaybeEither [Byte ] = convert[Byte ](sourceValue, hint )
63
63
64
- def convertToByteOpt [S : Type ](sourceValue : S ): Option [Byte ] = convertOpt[Byte ](sourceValue)
64
+ def convertToByteOpt [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Option [Byte ] = convertOpt[Byte ](sourceValue, hint )
65
65
66
- def convertToByteEx [S : Type ](sourceValue : S ): Byte = convertEx[Byte ](sourceValue)
66
+ def convertToByteEx [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Byte = convertEx[Byte ](sourceValue, hint )
67
67
68
- def convertToBoolean [S : Type ](sourceValue : S ): MaybeEither [Boolean ] = convert[Boolean ](sourceValue)
68
+ def convertToBoolean [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): MaybeEither [Boolean ] = convert[Boolean ](sourceValue, hint )
69
69
70
- def convertToBooleanOpt [S : Type ](sourceValue : S ): Option [Boolean ] = convertOpt[Boolean ](sourceValue)
70
+ def convertToBooleanOpt [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Option [Boolean ] = convertOpt[Boolean ](sourceValue, hint )
71
71
72
- def convertToBooleanEx [S : Type ](sourceValue : S ): Boolean = convertEx[Boolean ](sourceValue)
72
+ def convertToBooleanEx [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Boolean = convertEx[Boolean ](sourceValue, hint )
73
73
74
- def convertToShort [S : Type ](sourceValue : S ): MaybeEither [Short ] = convert[Short ](sourceValue)
74
+ def convertToShort [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): MaybeEither [Short ] = convert[Short ](sourceValue, hint )
75
75
76
- def convertToShortOpt [S : Type ](sourceValue : S ): Option [Short ] = convertOpt[Short ](sourceValue)
76
+ def convertToShortOpt [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Option [Short ] = convertOpt[Short ](sourceValue, hint )
77
77
78
- def convertToShortEx [S : Type ](sourceValue : S ): Short = convertEx[Short ](sourceValue)
78
+ def convertToShortEx [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Short = convertEx[Short ](sourceValue, hint )
79
79
80
- def convertToChar [S : Type ](sourceValue : S ): MaybeEither [Char ] = convert[Char ](sourceValue)
80
+ def convertToChar [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): MaybeEither [Char ] = convert[Char ](sourceValue, hint )
81
81
82
- def convertToCharOpt [S : Type ](sourceValue : S ): Option [Char ] = convertOpt[Char ](sourceValue)
82
+ def convertToCharOpt [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Option [Char ] = convertOpt[Char ](sourceValue, hint )
83
83
84
- def convertToCharEx [S : Type ](sourceValue : S ): Char = convertEx[Char ](sourceValue)
84
+ def convertToCharEx [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Char = convertEx[Char ](sourceValue, hint )
85
85
86
- def convertToInt [S : Type ](sourceValue : S ): MaybeEither [Int ] = convert[Int ](sourceValue)
86
+ def convertToInt [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): MaybeEither [Int ] = convert[Int ](sourceValue, hint )
87
87
88
- def convertToIntOpt [S : Type ](sourceValue : S ): Option [Int ] = convertOpt[Int ](sourceValue)
88
+ def convertToIntOpt [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Option [Int ] = convertOpt[Int ](sourceValue, hint )
89
89
90
- def convertToIntEx [S : Type ](sourceValue : S ): Int = convertEx[Int ](sourceValue)
90
+ def convertToIntEx [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Int = convertEx[Int ](sourceValue, hint )
91
91
92
- def convertToLong [S : Type ](sourceValue : S ): MaybeEither [Long ] = convert[Long ](sourceValue)
92
+ def convertToLong [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): MaybeEither [Long ] = convert[Long ](sourceValue, hint )
93
93
94
- def convertToLongOpt [S : Type ](sourceValue : S ): Option [Long ] = convertOpt[Long ](sourceValue)
94
+ def convertToLongOpt [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Option [Long ] = convertOpt[Long ](sourceValue, hint )
95
95
96
- def convertToLongEx [S : Type ](sourceValue : S ): Long = convertEx[Long ](sourceValue)
96
+ def convertToLongEx [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Long = convertEx[Long ](sourceValue, hint )
97
97
98
- def convertToFloat [S : Type ](sourceValue : S ): MaybeEither [Float ] = convert[Float ](sourceValue)
98
+ def convertToFloat [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): MaybeEither [Float ] = convert[Float ](sourceValue, hint )
99
99
100
- def convertToFloatOpt [S : Type ](sourceValue : S ): Option [Float ] = convertOpt[Float ](sourceValue)
100
+ def convertToFloatOpt [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Option [Float ] = convertOpt[Float ](sourceValue, hint )
101
101
102
- def convertToFloatEx [S : Type ](sourceValue : S ): Float = convertEx[Float ](sourceValue)
102
+ def convertToFloatEx [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Float = convertEx[Float ](sourceValue, hint )
103
103
104
- def convertToDouble [S : Type ](sourceValue : S ): MaybeEither [Double ] = convert[Double ](sourceValue)
104
+ def convertToDouble [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): MaybeEither [Double ] = convert[Double ](sourceValue, hint )
105
105
106
- def convertToDoubleOpt [S : Type ](sourceValue : S ): Option [Double ] = convertOpt[Double ](sourceValue)
106
+ def convertToDoubleOpt [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Option [Double ] = convertOpt[Double ](sourceValue, hint )
107
107
108
- def convertToDoubleEx [S : Type ](sourceValue : S ): Double = convertEx[Double ](sourceValue)
108
+ def convertToDoubleEx [S : Type ](sourceValue : S , hint : AnyRef = EmptyHint ): Double = convertEx[Double ](sourceValue, hint )
109
109
}
0 commit comments