mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-06-08 02:14:57 +00:00
refactoring: issue#2376 (#2491)
Changed all the switch expression according to the JAVA 17.
This commit is contained in:
@@ -44,23 +44,13 @@ public class PotionFactory {
|
||||
var potion = potions.get(type);
|
||||
if (potion == null) {
|
||||
switch (type) {
|
||||
case HEALING:
|
||||
potion = new HealingPotion();
|
||||
break;
|
||||
case HOLY_WATER:
|
||||
potion = new HolyWaterPotion();
|
||||
break;
|
||||
case INVISIBILITY:
|
||||
potion = new InvisibilityPotion();
|
||||
break;
|
||||
case POISON:
|
||||
potion = new PoisonPotion();
|
||||
break;
|
||||
case STRENGTH:
|
||||
potion = new StrengthPotion();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case HEALING -> potion = new HealingPotion();
|
||||
case HOLY_WATER -> potion = new HolyWaterPotion();
|
||||
case INVISIBILITY -> potion = new InvisibilityPotion();
|
||||
case POISON -> potion = new PoisonPotion();
|
||||
case STRENGTH -> potion = new StrengthPotion();
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
if (potion != null) {
|
||||
potions.put(type, potion);
|
||||
|
||||
Reference in New Issue
Block a user