Skip to content
This repository was archived by the owner on Aug 17, 2019. It is now read-only.

Commit fcc1540

Browse files
committed
Add Option[T] conversions for primitives
1 parent b12a123 commit fcc1540

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main/scala/com/ckkloverdos/convert/ConverterBase.scala

+16
Original file line numberDiff line numberDiff line change
@@ -61,33 +61,49 @@ trait ConverterBase {
6161

6262
def convertToByte[S: Type](sourceValue: S): Maybe[Byte] = convert[Byte](sourceValue)
6363

64+
def convertToByteOpt[S: Type](sourceValue: S): Option[Byte] = convertOpt[Byte](sourceValue)
65+
6466
def convertToByteEx[S: Type](sourceValue: S): Byte = convertEx[Byte](sourceValue)
6567

6668
def convertToBoolean[S: Type](sourceValue: S): Maybe[Boolean] = convert[Boolean](sourceValue)
6769

70+
def convertToBooleanOpt[S: Type](sourceValue: S): Option[Boolean] = convertOpt[Boolean](sourceValue)
71+
6872
def convertToBooleanEx[S: Type](sourceValue: S): Boolean = convertEx[Boolean](sourceValue)
6973

7074
def convertToShort[S: Type](sourceValue: S): Maybe[Short] = convert[Short](sourceValue)
7175

76+
def convertToShortOpt[S: Type](sourceValue: S): Option[Short] = convertOpt[Short](sourceValue)
77+
7278
def convertToShortEx[S: Type](sourceValue: S): Short = convertEx[Short](sourceValue)
7379

7480
def convertToChar[S: Type](sourceValue: S): Maybe[Char] = convert[Char](sourceValue)
7581

82+
def convertToCharOpt[S: Type](sourceValue: S): Option[Char] = convertOpt[Char](sourceValue)
83+
7684
def convertToCharEx[S: Type](sourceValue: S): Char = convertEx[Char](sourceValue)
7785

7886
def convertToInt[S: Type](sourceValue: S): Maybe[Int] = convert[Int](sourceValue)
7987

88+
def convertToIntOpt[S: Type](sourceValue: S): Option[Int] = convertOpt[Int](sourceValue)
89+
8090
def convertToIntEx[S: Type](sourceValue: S): Int = convertEx[Int](sourceValue)
8191

8292
def convertToLong[S: Type](sourceValue: S): Maybe[Long] = convert[Long](sourceValue)
8393

94+
def convertToLongOpt[S: Type](sourceValue: S): Option[Long] = convertOpt[Long](sourceValue)
95+
8496
def convertToLongEx[S: Type](sourceValue: S): Long = convertEx[Long](sourceValue)
8597

8698
def convertToFloat[S: Type](sourceValue: S): Maybe[Float] = convert[Float](sourceValue)
8799

100+
def convertToFloatOpt[S: Type](sourceValue: S): Option[Float] = convertOpt[Float](sourceValue)
101+
88102
def convertToFloatEx[S: Type](sourceValue: S): Float = convertEx[Float](sourceValue)
89103

90104
def convertToDouble[S: Type](sourceValue: S): Maybe[Double] = convert[Double](sourceValue)
91105

106+
def convertToDoubleOpt[S: Type](sourceValue: S): Option[Double] = convertOpt[Double](sourceValue)
107+
92108
def convertToDoubleEx[S: Type](sourceValue: S): Double = convertEx[Double](sourceValue)
93109
}

0 commit comments

Comments
 (0)