Class FlowGraphBuildingStrategyRegistry

java.lang.Object
com.alibaba.cloud.ai.graph.agent.flow.strategy.FlowGraphBuildingStrategyRegistry

public class FlowGraphBuildingStrategyRegistry extends Object
Registry for FlowGraphStrategy implementations. This allows for dynamic registration and lookup of graph building strategies, enabling extensibility without modifying core code.

The registry is thread-safe and supports runtime registration of new strategies.

  • Method Details

    • getInstance

      public static FlowGraphBuildingStrategyRegistry getInstance()
      Gets the singleton instance of the registry.
      Returns:
      the registry instance
    • registerStrategy

      public void registerStrategy(FlowGraphBuildingStrategy strategy)
      Registers a new graph building strategy.
      Parameters:
      strategy - the strategy to register
      Throws:
      IllegalArgumentException - if strategy is null or type is already registered
    • getStrategy

      public FlowGraphBuildingStrategy getStrategy(String type)
      Gets a strategy by type.
      Parameters:
      type - the strategy type
      Returns:
      the strategy implementation
      Throws:
      IllegalArgumentException - if no strategy is found for the type
    • hasStrategy

      public boolean hasStrategy(String type)
      Checks if a strategy is registered for the given type.
      Parameters:
      type - the strategy type
      Returns:
      true if a strategy is registered, false otherwise
    • getRegisteredTypes

      public Set<String> getRegisteredTypes()
      Gets all registered strategy types.
      Returns:
      a set of all registered strategy types
    • unregisterStrategy

      public FlowGraphBuildingStrategy unregisterStrategy(String type)
      Unregisters a strategy (mainly for testing purposes).
      Parameters:
      type - the strategy type to unregister
      Returns:
      the unregistered strategy, or null if none was found
    • clear

      public void clear()
      Clears all registered strategies (mainly for testing purposes).