two way adapter???????

首先感谢banq大哥给我们整理了这么多关于设计模式的文章。非常感谢!!
我看到你讲的adapter那章时,觉得two-way-adapter你是不是没解释清楚。我想代码是不是应该如下:



public interface IRoundPeg {
void insertIntoHole(String str);
}

public interface ISquarePeg {
void insert(String str);
}

public class RoundPeg implements IRoundPeg{

public void insertIntoHole(String str){
System.out.println("SquarePeg------->insert");
}
}

public class SquarePeg implements ISquarePeg{

public void insert(String str){
System.out.println(
"SquarePeg------->insert");
}

public void someOtherMethod(){

}
}

public class TwoWayPegAdapter implements IRoundPeg,ISquarePeg{
private IRoundPeg roundPeg;
private ISquarePeg squarePeg;

public TwoWayPegAdapter(IRoundPeg roundPeg,ISquarePeg squarePeg) {
this.roundPeg=roundPeg;
this.squarePeg=squarePeg;
}

public void insertIntoHole(String str) {
roundPeg.insertIntoHole(str);
}

public void insert(String str) {
squarePeg.insert(str);
}

}

嗯不错,可给大家做参考。