Skip to content

Commit c23f58e

Browse files
committed
[refactor] Update flyweight pattern.
1 parent eb9b5fd commit c23f58e

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

flyweight/src/main/java/com/iluwatar/Potion.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
*/
88
public interface Potion {
99

10-
public void drink();
11-
10+
void drink();
1211
}

flyweight/src/main/java/com/iluwatar/PotionFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.iluwatar;
22

33
import java.util.EnumMap;
4+
import java.util.Map;
45

56
/**
67
*
@@ -12,7 +13,7 @@
1213
*/
1314
public class PotionFactory {
1415

15-
private EnumMap<PotionType, Potion> potions;
16+
private final Map<PotionType, Potion> potions;
1617

1718
public PotionFactory() {
1819
potions = new EnumMap<>(PotionType.class);

flyweight/src/main/java/com/iluwatar/PotionType.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
*/
88
public enum PotionType {
99

10-
HEALING, INVISIBILITY, STRENGTH, HOLY_WATER, POISON;
11-
10+
HEALING, INVISIBILITY, STRENGTH, HOLY_WATER, POISON
1211
}

0 commit comments

Comments
 (0)