This module defines an AdapterFabric helper.
definition
Adapter augmentations.
Specifies the name of the parent class (java.lang.Object
by default).
Usage:
let arrayListAdapter = Adapter()
: extends("java.util.ArrayList")
Provides a method implementation
Usage:
let result = array[1,2,3]
let runnerAdapter = Adapter()
: interfaces(["java.io.Serializable", "java.lang.Runnable"])
: implements("run", |this| {
for (var i = 0, i < result: length(), i = i + 1) {
result: set(i, result: get(i) + 10)
}
})
Defines interface(s) for the Adapter:
Usage:
let runnerAdapter = Adapter()
: interfaces(["java.io.Serializable", "java.lang.Runnable"])
Returns an instance based on a configuration (also see adapter: definition()
).
Returns an instance of the adapted Java class.
The parameters are the parameters of the base class constructor.
Returns an instance of the adapted Java class.
Usage:
let result = array[1,2,3]
let runnerAdapter = Adapter()
: interfaces(["java.io.Serializable", "java.lang.Runnable"])
: implements("run", |this| {
for (var i = 0, i < result: length(), i = i + 1) {
result: set(i, result: get(i) + 10)
}
})
let runner = runnerAdapter: newInstance()
runner: run()
Provides a method override.
Usage:
let objectAdapter = Adapter()
: overrides("toString", |super, this| -> ">>> " + super(this))
println(objectAdapter: newInstance(): toString())
This prints something like: >>> $Golo$Adapter$0@2aaf7cc2
.
Adapter constructor.