public interface Mixin
A poor-man's implementation of mixins, also known as stateful traits, in Java. Interfaces that extend the
Mixinsuperinterface can retrieve state values for the mixin with
state(Class, Factory). This obviates the need for hand delegation of an aggregate value when providing an interface implementation for an object that already has a base class. For example, the
BaseRepeaterclass can be used when there is no base class for an object, or
RepeaterMixincan be used if there is already a base class. Both achieve the same result, namely implementing the
Because mixin values are retrieved from an identity map, performance is impacted versus a field implementation and should be considered in design.
- jonathanl (shibo)