Documentation for gololang.Adapters

This module defines an AdapterFabric helper.

Structs

adapter

Members

Augmentations

gololang.Adapters.types.adapter

Adapter augmentations.

extends(this, className)

Specifies the name of the parent class (java.lang.Object by default).

Usage:

let arrayListAdapter = Adapter()
  : extends("java.util.ArrayList")

implements(this, methodName, closure)

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)
      }
    })

interfaces(this, interfacesTuple)

Defines interface(s) for the Adapter:

Usage:

let runnerAdapter = Adapter()
  : interfaces(["java.io.Serializable", "java.lang.Runnable"])

maker(this)

Returns an instance based on a configuration (also see adapter: definition()).

newInstance(this, args...)

Returns an instance of the adapted Java class.

The parameters are the parameters of the base class constructor.

newInstance(this)

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()

overrides(this, methodName, closure)

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.

Functions

Adapter()

Adapter constructor.