java traits or mixins pattern?

前端 未结 8 2220
小蘑菇
小蘑菇 2020-12-16 14:02

Is there a way to emulate mixins or traits in java? basically, I need a way to do multiple inheritance so I can add common business logic to several classes

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-16 14:28

    Implementing simple mixin/traits support in java using CGLib/javassit is quite easy. You can take a look for instance here for small example. More complete, ready to use solution might be found: here

提交回复
热议问题