Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
88 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
abstract-factory/src/main/java/com/iluwatar/abstractfactory/Kingdom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.iluwatar.abstractfactory; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class Kingdom { | ||
|
||
private King king; | ||
private Castle castle; | ||
private Army army; | ||
|
||
/** | ||
* The factory of kingdom factories. | ||
*/ | ||
public static class FactoryMaker { | ||
|
||
/** | ||
* Enumeration for the different types of Kingdoms. | ||
*/ | ||
public enum KingdomType { | ||
ELF, ORC | ||
} | ||
|
||
/** | ||
* The factory method to create KingdomFactory concrete objects. | ||
*/ | ||
public static KingdomFactory makeFactory(KingdomType type) { | ||
switch (type) { | ||
case ELF: | ||
return new ElfKingdomFactory(); | ||
case ORC: | ||
return new OrcKingdomFactory(); | ||
default: | ||
throw new IllegalArgumentException("KingdomType not supported."); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters