diff --git a/flyweight/src/main/java/com/iluwatar/flyweight/App.java b/flyweight/src/main/java/com/iluwatar/flyweight/App.java index 3aa41cf2c..c08ba78a3 100644 --- a/flyweight/src/main/java/com/iluwatar/flyweight/App.java +++ b/flyweight/src/main/java/com/iluwatar/flyweight/App.java @@ -4,18 +4,22 @@ package com.iluwatar.flyweight; * * Flyweight pattern is useful when the program needs a huge amount of objects. * It provides means to decrease resource usage by sharing object instances. - * - * In this example AlchemistShop has great amount of potions on its shelves. - * To fill the shelves AlchemistShop uses PotionFactory (which represents - * the Flyweight in this example). Internally PotionFactory holds a map + *
+ * In this example {@link AlchemistShop} has great amount of potions on its shelves. + * To fill the shelves {@link AlchemistShop} uses {@link PotionFactory} (which represents + * the Flyweight in this example). Internally {@link PotionFactory} holds a map * of the potions and lazily creates new ones when requested. - * + *
* To enable safe sharing, between clients and threads, Flyweight objects must * be immutable. Flyweight objects are by definition value objects. * */ public class App { + /** + * Program entry point + * @param args command line args + */ public static void main(String[] args) { AlchemistShop alchemistShop = new AlchemistShop(); alchemistShop.enumerate(); diff --git a/flyweight/src/main/java/com/iluwatar/flyweight/HealingPotion.java b/flyweight/src/main/java/com/iluwatar/flyweight/HealingPotion.java index 397cca428..a5f8f4fb8 100644 --- a/flyweight/src/main/java/com/iluwatar/flyweight/HealingPotion.java +++ b/flyweight/src/main/java/com/iluwatar/flyweight/HealingPotion.java @@ -1,11 +1,16 @@ -package com.iluwatar.flyweight; - -public class HealingPotion implements Potion { - - @Override - public void drink() { - System.out.println("You feel healed. (Potion=" - + System.identityHashCode(this) + ")"); - } - -} +package com.iluwatar.flyweight; + +/** + * + * HealingPotion + * + */ +public class HealingPotion implements Potion { + + @Override + public void drink() { + System.out.println("You feel healed. (Potion=" + + System.identityHashCode(this) + ")"); + } + +} diff --git a/flyweight/src/main/java/com/iluwatar/flyweight/HolyWaterPotion.java b/flyweight/src/main/java/com/iluwatar/flyweight/HolyWaterPotion.java index df4c4009e..750e3c568 100644 --- a/flyweight/src/main/java/com/iluwatar/flyweight/HolyWaterPotion.java +++ b/flyweight/src/main/java/com/iluwatar/flyweight/HolyWaterPotion.java @@ -1,11 +1,16 @@ -package com.iluwatar.flyweight; - -public class HolyWaterPotion implements Potion { - - @Override - public void drink() { - System.out.println("You feel blessed. (Potion=" - + System.identityHashCode(this) + ")"); - } - -} +package com.iluwatar.flyweight; + +/** + * + * HolyWaterPotion + * + */ +public class HolyWaterPotion implements Potion { + + @Override + public void drink() { + System.out.println("You feel blessed. (Potion=" + + System.identityHashCode(this) + ")"); + } + +} diff --git a/flyweight/src/main/java/com/iluwatar/flyweight/InvisibilityPotion.java b/flyweight/src/main/java/com/iluwatar/flyweight/InvisibilityPotion.java index 2156b1017..db9d261d5 100644 --- a/flyweight/src/main/java/com/iluwatar/flyweight/InvisibilityPotion.java +++ b/flyweight/src/main/java/com/iluwatar/flyweight/InvisibilityPotion.java @@ -1,11 +1,16 @@ -package com.iluwatar.flyweight; - -public class InvisibilityPotion implements Potion { - - @Override - public void drink() { - System.out.println("You become invisible. (Potion=" - + System.identityHashCode(this) + ")"); - } - -} +package com.iluwatar.flyweight; + +/** + * + * InvisibilityPotion + * + */ +public class InvisibilityPotion implements Potion { + + @Override + public void drink() { + System.out.println("You become invisible. (Potion=" + + System.identityHashCode(this) + ")"); + } + +} diff --git a/flyweight/src/main/java/com/iluwatar/flyweight/PoisonPotion.java b/flyweight/src/main/java/com/iluwatar/flyweight/PoisonPotion.java index 2dcfab7d3..dfcd3c38d 100644 --- a/flyweight/src/main/java/com/iluwatar/flyweight/PoisonPotion.java +++ b/flyweight/src/main/java/com/iluwatar/flyweight/PoisonPotion.java @@ -1,11 +1,16 @@ -package com.iluwatar.flyweight; - -public class PoisonPotion implements Potion { - - @Override - public void drink() { - System.out.println("Urgh! This is poisonous. (Potion=" - + System.identityHashCode(this) + ")"); - } - -} +package com.iluwatar.flyweight; + +/** + * + * PoisonPotion + * + */ +public class PoisonPotion implements Potion { + + @Override + public void drink() { + System.out.println("Urgh! This is poisonous. (Potion=" + + System.identityHashCode(this) + ")"); + } + +} diff --git a/flyweight/src/main/java/com/iluwatar/flyweight/StrengthPotion.java b/flyweight/src/main/java/com/iluwatar/flyweight/StrengthPotion.java index a1ffcdc53..49083cf7c 100644 --- a/flyweight/src/main/java/com/iluwatar/flyweight/StrengthPotion.java +++ b/flyweight/src/main/java/com/iluwatar/flyweight/StrengthPotion.java @@ -1,10 +1,15 @@ -package com.iluwatar.flyweight; - -public class StrengthPotion implements Potion { - - @Override - public void drink() { - System.out.println("You feel strong. (Potion=" - + System.identityHashCode(this) + ")"); - } -} +package com.iluwatar.flyweight; + +/** + * + * StrengthPotion + * + */ +public class StrengthPotion implements Potion { + + @Override + public void drink() { + System.out.println("You feel strong. (Potion=" + + System.identityHashCode(this) + ")"); + } +} diff --git a/flyweight/src/test/java/com/iluwatar/flyweight/AppTest.java b/flyweight/src/test/java/com/iluwatar/flyweight/AppTest.java index 2c93d0e10..f3b033ba7 100644 --- a/flyweight/src/test/java/com/iluwatar/flyweight/AppTest.java +++ b/flyweight/src/test/java/com/iluwatar/flyweight/AppTest.java @@ -1,14 +1,19 @@ -package com.iluwatar.flyweight; - -import org.junit.Test; - -import com.iluwatar.flyweight.App; - -public class AppTest { - - @Test - public void test() { - String[] args = {}; - App.main(args); - } -} +package com.iluwatar.flyweight; + +import org.junit.Test; + +import com.iluwatar.flyweight.App; + +/** + * + * Application test + * + */ +public class AppTest { + + @Test + public void test() { + String[] args = {}; + App.main(args); + } +}