Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Objectteams » Multidispatch pattern with OT/J
Multidispatch pattern with OT/J [message #568322] Mon, 15 February 2010 09:11
Eugene Hutorny is currently offline Eugene Hutorny
Messages: 109
Registered: January 2010
Senior Member
The list of OT/J does not mention multidispatch.
With smart lifting OT/J can easily provide multidispatch capabilities:

public class Shape {/*...*/}

public class Square extends Shape {/*...*/}

public class Triangle extends Shape {/*...*/}

public team class Printer {
protected class PrintableShape playedBy Shape {
protected String print() {
return "Shape";
protected class PrintableTriangle extends PrintableShape playedBy Triangle {
protected String print() {
return "Triangle";
protected class PrintableSquare extends PrintableShape playedBy Square {
protected String print() {
return "Square";
public String print(Shape as PrintableShape shape) {
return shape.print();

public class TheTest {
final Printer printer = new Printer();
Shape triangle = new Triangle();
Shape square = new Square();

public void run() {
System.out.println(printer.print(triangle)); // prints Triangle
System.out.println(printer.print(square)); // prints Square
Previous Topic:OTDT 1.4.0M3 released
Next Topic:A question on design motivation for callout syntax
Goto Forum:

Current Time: Wed Aug 20 20:25:25 EDT 2014

Powered by FUDForum. Page generated in 0.01489 seconds