fieldValueOrNullAs

fun <T> Any.fieldValueOrNullAs(fieldName: String, type: Class<*>? = null): T?

读取实例字段值并转为指定类型,失败时返回 null

Parameters

fieldName

字段名

type

可选字段类型,用于进一步确认匹配结果