Class CmdInfoFlyweightFactory

java.lang.Object
com.iohao.net.framework.core.CmdInfoFlyweightFactory

public final class CmdInfoFlyweightFactory extends Object
Factory that produces cached CmdInfo instances using the flyweight pattern.

The underlying caching strategy is selected at class-load time based on CmdInfoFlyweightStrategy configured in CoreGlobalConfig.setting. When the command space exceeds 128 in either dimension the factory automatically falls back to a Map-based implementation.

Author:
渔民小镇
date:
2021-12-20
  • Constructor Details

    • CmdInfoFlyweightFactory

      public CmdInfoFlyweightFactory()
  • Method Details

    • of

      public static CmdInfo of(int cmd, int subCmd)
      Obtain a cached CmdInfo for the given command and sub-command pair.
      Parameters:
      cmd - the primary command ID
      subCmd - the sub-command ID
      Returns:
      the flyweight CmdInfo instance
    • of

      public static CmdInfo of(int cmdMerge)
      Obtain a cached CmdInfo for the given merged command value.
      Parameters:
      cmdMerge - the merged command value (cmd and subCmd packed into one int)
      Returns:
      the flyweight CmdInfo instance