VariableWrapper

包装非 Variable 对象成 Variable 对象, 一般不直接创建, 而是通过 VariableWrappers.wrap 方法创建.

Author

M8Test, [email protected], https://m8test.com

Functions

Link copied to clipboard
abstract fun also(block: (Any) -> Unit): ObjectWrapper<Any>

对 ObjectWrapper 调用给定的 block 函数,并返回 ObjectWrapper 本身。

Link copied to clipboard
abstract fun apply(block: Any.() -> Unit): ObjectWrapper<Any>

对 ObjectWrapper 调用给定的 block 函数,并返回 ObjectWrapper 本身。

Link copied to clipboard
abstract fun getGlobalName(): String

获取作为全局变量时的名称.

Link copied to clipboard
abstract override fun getOrigin(): Any

获取被包装的对象.

Link copied to clipboard
abstract fun getPublicType(): Type

获取 Variable 注入到脚本时需要显示的类型.

Link copied to clipboard
abstract fun isPrefixRequired(): Boolean

是否需要添加前缀, 每种编程语言添加的前缀不一样, 前缀可以通过 Language.getVariablePrefix 获取.

Link copied to clipboard
abstract fun isSuffixRequired(): Boolean

是否需要添加后缀, 每种编程语言添加的后缀不一样, 后缀可以通过 Language.getVariableSuffix 获取.

Link copied to clipboard
abstract fun <R> let(block: (Any) -> R): ObjectWrapper<R>?

对 ObjectWrapper 调用给定的 block 函数,并返回 block 函数的结果包装在 ObjectWrapper 中。

Link copied to clipboard
abstract fun <R> run(block: Any.() -> R): ObjectWrapper<R>?

对 ObjectWrapper 调用给定的 block 函数,并返回 block 函数的结果包装在 ObjectWrapper 中。

Link copied to clipboard
abstract fun takeIf(predicate: (Any) -> Boolean): ObjectWrapper<Any>?

如果 ObjectWrapper 满足给定的 predicate,则返回 ObjectWrapper 本身,否则返回 null 包装在 ObjectWrapper? 中。

Link copied to clipboard
abstract fun takeUnless(predicate: (Any) -> Boolean): ObjectWrapper<Any>?

如果 ObjectWrapper 不满足给定的 predicate,则返回 ObjectWrapper 本身,否则返回 null 包装在 ObjectWrapper? 中。