MethodDispatcher

A MethodDispatcher organizes a set of methods with identical signatures - possibly defined in distinct classes - and is able to dispatch to an applicable method by analyzing the first argument of - possibly multiple - supplied arguments.

Constructors

Link copied to clipboard
constructor(instance: Any, methodName: String)

create a new MethodDispatcher. The instance will collect all matching methods of the supplied instance class.

constructor(methodName: String)

create a new MethodDispatcher. The instance will collect all matching methods of its own class.

constructor(original: MethodDispatcher)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun addMethods(instance: Any, methodName: String)

look for all named methods of the instance's class and add them to the list of methods that can be dispatched.

Link copied to clipboard
fun dispatch(vararg args: Any): Any

Invoke the most applicable method with respect to the supplied argument and returns its return value.

Link copied to clipboard
Link copied to clipboard
fun foo()
Link copied to clipboard
Link copied to clipboard

return true if an applicable method for the supplied argument is available, false otherwise.

Link copied to clipboard
fun replaceMethods(instance: Any, methodName: String)

look for all named methods of the instance's class and add them to the list of methods that can be dispatched possibly replacing existing methods.