Added comments about object sharing in Flyweight example + some minor
fixes.
This commit is contained in:
@ -11,8 +11,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class AlchemistShop {
|
public class AlchemistShop {
|
||||||
|
|
||||||
List<Potion> topShelf;
|
private List<Potion> topShelf;
|
||||||
List<Potion> bottomShelf;
|
private List<Potion> bottomShelf;
|
||||||
|
|
||||||
public AlchemistShop() {
|
public AlchemistShop() {
|
||||||
topShelf = new ArrayList<>();
|
topShelf = new ArrayList<>();
|
||||||
|
@ -10,6 +10,9 @@ package com.iluwatar.flyweight;
|
|||||||
* the Flyweight in this example). Internally PotionFactory holds a map
|
* the Flyweight in this example). Internally PotionFactory holds a map
|
||||||
* of the potions and lazily creates new ones when requested.
|
* 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 {
|
public class App {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user