Cake pattern with Java8 possible?

前端 未结 5 1470
无人共我
无人共我 2020-12-24 06:32

I just wonder: with Java 8, and the possibility to add implementation in interfaces (a bit like Scala traits), will it be possible to implement the cake pattern, like we can

5条回答
  •  萌比男神i
    2020-12-24 06:57

    Ignoring the new functionality in Java 8 you can in theory do the Cake Pattern in Java 5 and above using compile time AspectJ ITDs.

    AspectJ DTO's allow you to make Mixins. The only annoying thing is that you will have to make two artifacts: the aspect (ITD) and the interface. However ITDs allow you to do some crazy stuff like add annotations to classes that implement an interface.

提交回复
热议问题