Package Structural.Flyweight
Class FlyweightFactory
java.lang.Object
Structural.Flyweight.FlyweightFactory
Factory for creating and managing Flyweight objects.
Ensures that shared Flyweight objects are reused rather than created multiple times.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetFlyweight(String intrinsicState) Retrieves a Flyweight object with the given intrinsic state.voidDisplays the current Flyweights managed by the factory.
-
Constructor Details
-
FlyweightFactory
public FlyweightFactory()Default constructor for FlyweightFactory.
-
-
Method Details
-
getFlyweight
Retrieves a Flyweight object with the given intrinsic state. If the Flyweight does not exist, it is created and stored.- Parameters:
intrinsicState- The shared intrinsic state of the Flyweight.- Returns:
- A Flyweight object.
-
listFlyweights
public void listFlyweights()Displays the current Flyweights managed by the factory.
-