Class FlowGraphBuildingStrategyRegistry
java.lang.Object
com.alibaba.cloud.ai.graph.agent.flow.strategy.FlowGraphBuildingStrategyRegistry
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 Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all registered strategies (mainly for testing purposes).Gets the singleton instance of the registry.Gets all registered strategy types.getStrategy(String type) Gets a strategy by type.booleanhasStrategy(String type) Checks if a strategy is registered for the given type.voidregisterStrategy(FlowGraphBuildingStrategy strategy) Registers a new graph building strategy.unregisterStrategy(String type) Unregisters a strategy (mainly for testing purposes).
-
Method Details
-
getInstance
Gets the singleton instance of the registry.- Returns:
- the registry instance
-
registerStrategy
Registers a new graph building strategy.- Parameters:
strategy- the strategy to register- Throws:
IllegalArgumentException- if strategy is null or type is already registered
-
getStrategy
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
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
Gets all registered strategy types.- Returns:
- a set of all registered strategy types
-
unregisterStrategy
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).
-