, , , . / getters/equals/hashCode/toString . , interface Action
interface Command<T extends Action> {
T getAction();
}
class AbstractCommand<T extends Action> implements Command<T> {
public T getAction() { ... }
}
interface Event<T extends Action> {
T getAction();
}
class AbstractEvent<T extends Action> implements Event<T> {
public T getAction() { ... }
}
.
class ConcreteAction implements Action {
}
class ConcreteCommand extends AbstractCommand<ConcreteAction> { ... }
class ConcreteEvent extends AbstractEvent<ConcreteAction> { ... }
- , ConcreteCommand ConcreteEvent.
The inheritance model here is very simple. You may only need to do more in rare cases than just extend abstract classes without using anything but the usual Action. And in the case when there are no properties necessary for Action, just define class EmptyAction implements Actionfor use in these types of commands and events.
source
share