/** * adds a new search strategy with a certain weight. * * @param strategy strategy to be added * @param weight of corresponding strategy to be added * @throws java.lang.IllegalStateException if strategy is null OR weight < 0 */ public void addStrategy(SearchStrategy strategy, double weight) { if (strategy == null) { throw new IllegalStateException("strategy is null. make sure adding a valid strategy."); } if (id2index.keySet().contains(strategy.getId())) { throw new IllegalStateException( "strategyId " + strategy.getId() + " already in use. replace strateId in your config file or code with a unique strategy id"); } if (weight < 0.0) { throw new IllegalStateException("weight is lower than zero."); } id2index.put(strategy.getId(), strategyIndex); strategyIndex++; strategies.add(strategy); weights.add(weight); sumWeights += weight; }
public void addSearchStrategyModuleListener(SearchStrategyModuleListener moduleListener) { for (SearchStrategy s : strategies) { s.addModuleListener(moduleListener); } }