#107 Flyweight example JavaDoc
This commit is contained in:
		@@ -4,18 +4,22 @@ package com.iluwatar.flyweight;
 | 
				
			|||||||
 * 
 | 
					 * 
 | 
				
			||||||
 * Flyweight pattern is useful when the program needs a huge amount of objects.
 | 
					 * Flyweight pattern is useful when the program needs a huge amount of objects.
 | 
				
			||||||
 * It provides means to decrease resource usage by sharing object instances.
 | 
					 * It provides means to decrease resource usage by sharing object instances.
 | 
				
			||||||
 * 
 | 
					 * <p>
 | 
				
			||||||
 * In this example AlchemistShop has great amount of potions on its shelves.
 | 
					 * In this example {@link AlchemistShop} has great amount of potions on its shelves.
 | 
				
			||||||
 * To fill the shelves AlchemistShop uses PotionFactory (which represents
 | 
					 * To fill the shelves {@link AlchemistShop} uses {@link PotionFactory} (which represents
 | 
				
			||||||
 * the Flyweight in this example). Internally PotionFactory holds a map
 | 
					 * the Flyweight in this example). Internally {@link PotionFactory} holds a map
 | 
				
			||||||
 * of the potions and lazily creates new ones when requested.
 | 
					 * of the potions and lazily creates new ones when requested.
 | 
				
			||||||
 * 
 | 
					 * <p>
 | 
				
			||||||
 * To enable safe sharing, between clients and threads, Flyweight objects must 
 | 
					 * To enable safe sharing, between clients and threads, Flyweight objects must 
 | 
				
			||||||
 * be immutable. Flyweight objects are by definition value objects.
 | 
					 * be immutable. Flyweight objects are by definition value objects.
 | 
				
			||||||
 * 
 | 
					 * 
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class App {
 | 
					public class App {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Program entry point
 | 
				
			||||||
 | 
						 * @param args command line args
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
	public static void main(String[] args) {
 | 
						public static void main(String[] args) {
 | 
				
			||||||
		AlchemistShop alchemistShop = new AlchemistShop();
 | 
							AlchemistShop alchemistShop = new AlchemistShop();
 | 
				
			||||||
		alchemistShop.enumerate();
 | 
							alchemistShop.enumerate();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,10 @@
 | 
				
			|||||||
package com.iluwatar.flyweight;
 | 
					package com.iluwatar.flyweight;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * HealingPotion
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class HealingPotion implements Potion {
 | 
					public class HealingPotion implements Potion {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,10 @@
 | 
				
			|||||||
package com.iluwatar.flyweight;
 | 
					package com.iluwatar.flyweight;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * HolyWaterPotion
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class HolyWaterPotion implements Potion {
 | 
					public class HolyWaterPotion implements Potion {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,10 @@
 | 
				
			|||||||
package com.iluwatar.flyweight;
 | 
					package com.iluwatar.flyweight;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * InvisibilityPotion
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class InvisibilityPotion implements Potion {
 | 
					public class InvisibilityPotion implements Potion {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,10 @@
 | 
				
			|||||||
package com.iluwatar.flyweight;
 | 
					package com.iluwatar.flyweight;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * PoisonPotion
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class PoisonPotion implements Potion {
 | 
					public class PoisonPotion implements Potion {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,10 @@
 | 
				
			|||||||
package com.iluwatar.flyweight;
 | 
					package com.iluwatar.flyweight;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * StrengthPotion
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class StrengthPotion implements Potion {
 | 
					public class StrengthPotion implements Potion {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,11 @@ import org.junit.Test;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.iluwatar.flyweight.App;
 | 
					import com.iluwatar.flyweight.App;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * Application test
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
public class AppTest {
 | 
					public class AppTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Test
 | 
						@Test
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user