docs: #2546 Remove code repetition from flyweight README (#2926)

This commit is contained in:
Samuel Souza authored and GitHub committed 2024-05-21 08:53:50 +03:00
1 parent 547cf20140
commit 3b2098b80d
1 file changed
+4 -12
+4 -12
View File
@@ -77,21 +77,13 @@ public class PotionFactory {
var potion = potions.get(type); var potion = potions.get(type);
if (potion == null) { if (potion == null) {
switch (type) { switch (type) {
case HEALING -> { case HEALING -> potion = new HealingPotion();
potion = new HealingPotion(); case HOLY_WATER -> potion = new HolyWaterPotion();
potions.put(type, potion); case INVISIBILITY -> potion = new InvisibilityPotion();
}
case HOLY_WATER -> {
potion = new HolyWaterPotion();
potions.put(type, potion);
}
case INVISIBILITY -> {
potion = new InvisibilityPotion();
potions.put(type, potion);
}
default -> { default -> {
} }
} }
potions.put(type, potion);
} }
return potion; return potion;
} }