Automatic delegations
You are here :

Sub nodes

Recent changes
Site plan
 
 

NOT IMPLEMENTED YET !

Single inheritance, multiple interface implementation

As Nosica (like Java) support only single inheritance, it can be quite annoying to have to manually implements an interface by manually forwarding methods to an object like in :

// interfaces
interface A {
  sub f();
}
interface B {
  sub g();
}
// one implementation
class AImpl implements A {
  public sub f() {}
}
class BImpl implements B {
  public sub g() {}
}
// manual implementation
class C extends A implements B {
  private BImpl b = new BImpl();
  public sub g() {
    b.g(); // manually use b to implement method B.g
  }
}

Automatic delegation

Instead of doing so, you can use automatic delegation using the "proxy" notation.

Syntax :

 class Enclosing implements I {
   public, private, protected TypeName fieldName proxies I;
 }

Sample :

class C extends A implements B {
  private BImpl b proxies B; // implements automatically all methods of
                             // interface B by forwarding all unimplemented 
                             // methods to 'b'
}

More information

See this bug report

NOT IMPLEMENTED YET !

Propulsed by Wiclear