You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
441 B

import java.util.ArrayList;
import java.util.List;
public class StrategyFactory2 {
private final List<CrawlStrategy2> strategies = new ArrayList<>();
public void registerStrategy(CrawlStrategy2 strategy) {
strategies.add(strategy);
}
public CrawlStrategy2 getMatchStrategy(String url) {
for (CrawlStrategy2 s : strategies) {
if (s.supports(url)) return s;
}
return null;
}
}