jkbbwr
01/18/2018, 2:28 PMinline fun <reified T> Reader.readFirst(fieldId: Int): T {
val field = this.getFirst(fieldId)
val result: Any = when {
Byte::class is T -> {
field.asByte()
}
ByteArray::class is T -> {
field.asByteArray()
}
Short::class is T -> {
field.asShort()
}
Int::class is T -> {
field.asInt()
}
Long::class is T -> {
field.asLong()
}
Date::class is T -> {
field.asDate()
}
UUID::class is T -> {
field.asUUID()
}
String::class is T -> {
field.asString()
}
else -> {
throw Exception("Non supported type ${T::class}")
}
}
return result as T
}