ReflectUtil
object ReflectUtil
Description: Interface layer (outer layer) object and protocol layer (bottom layer) object conversion Reflection class
java
object ReflectUtil {
private const val TAG = "ReflectUtil"
private const val SUFFIX_FIELD = "_"
/**
* The method name corresponding to the Kotlin enumeration constructor
*/
private const val ENUM_METHOD_NAME = "getValue"
/**
*
Kotlin enumeration class finds the method name of the specified enumeration
*/
private const val FIND_ENUM_METHOD_NAME = "findEnum"
}
method evaluationToProto
fun <T, D> evaluationToProto(bean: T, builder: D, clazzT: Class<T>, clazzD: Class<D>)
Description: Assign the properties of the interface layer object to the protocol layer object
Input parameters: bean: interface layer object builder: protocol layer object clazzT: class T clazzD: class D
Output parameters: None。
Related parameters: None。
method evaluationFromProto
fun <T, D> evaluationFromProto(bean: T, builder: D, clazzT: Class<T>, clazzD: Class<D>)
Description: Assign the properties of the protocol layer object to the interface layer object
Input parameters: bean: interface layer object builder: protocol layer object clazzT: class declared fields clazzD: class declared fields
Output parameters: None。
Related parameters: None。
method isBasicClass
private fun isBasicClass(clazz: Class<*>): Boolean
Description: Whether it is a basic data type and String or an enumeration
Input parameters: clazz: class declared fields
Output parameters: true or false
Related parameters: None。
method jointFieldName
private fun jointFieldName(field: Field, suffix: String = SUFFIX_FIELD): String
Description: Join field names with suffix
Input parameters: field: field name suffix: suffix for append to field
Output parameters: Merged value with suffix
Related parameters: None。