package com.lukouguoji.module_base.common

import kotlin.String

object String {

    /**
     * 空字符串转null
     */
    fun String?.emptyToNull(): String? {
        return if (this == null || this == "") {
            null
        } else {
            this
        }
    }

    /**
     * 判断是否是int型
     */
    fun String.isValidInt(): Boolean {
        var isInt: Boolean = false
        try {
            this.toInt()
            isInt = true
        } catch (e: NumberFormatException) {
            isInt = false
        }
        return isInt
    }
}