mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 18:58:44 +00:00
first version of pattern without Tests
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package units;
|
||||
|
||||
import abstractextensions.CommanderExtension;
|
||||
import abstractextensions.UnitExtension;
|
||||
import concreteextensions.Commander;
|
||||
|
||||
/**
|
||||
* Created by Srdjan on 27-Apr-17.
|
||||
*/
|
||||
public class CommanderUnit extends Unit {
|
||||
|
||||
private CommanderExtension commanderExtension;
|
||||
|
||||
public CommanderUnit(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnitExtension getUnitExtension(String extensionName) {
|
||||
|
||||
if (extensionName.equals("CommanderExtension")) {
|
||||
if (commanderExtension == null) {
|
||||
commanderExtension = new Commander(this);
|
||||
}
|
||||
return commanderExtension;
|
||||
}
|
||||
|
||||
return super.getUnitExtension(extensionName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user