All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.oneeyedmen.kSera.InvokeAction.kt Maven / Gradle / Ivy

The newest version!
package com.oneeyedmen.kSera

import org.jmock.api.Invocation
import org.jmock.lib.action.CustomAction

class InvokeAction(private val description: String, private val block: (Invocation) -> R)
: TypedAction by UntypedInvokeAction(description, block).asTyped()


class UntypedInvokeAction(description: String, private val lambda: (Invocation) -> R) : CustomAction(description) {

    override fun invoke(invocation: Invocation): R? {
        val result = lambda(invocation)
        return if (result == Unit) null else result // Java reflection doesn't understand Unit
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy