Class FlyweightFactory

java.lang.Object
Structural.Flyweight.FlyweightFactory

public class FlyweightFactory extends Object
Factory for creating and managing Flyweight objects. Ensures that shared Flyweight objects are reused rather than created multiple times.
  • Constructor Details

    • FlyweightFactory

      public FlyweightFactory()
      Default constructor for FlyweightFactory.
  • Method Details

    • getFlyweight

      public Flyweight getFlyweight(String intrinsicState)
      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.