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.
23 lines
677 B
23 lines
677 B
package com.woniu.celuejj.celue;
|
|
|
|
|
|
import java.util.Arrays;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
|
|
public class StrategyRunnerImpl implements StrategyRunner {
|
|
|
|
private static final List<Strategy> STRATEGIES = Arrays.asList(new ConcreteStrategyA(), new ConcreteStrategyB(), new ConcreteStrategyC());
|
|
private static Map<String, Strategy> STRATEGY_MAP = new HashMap<>();
|
|
|
|
static {
|
|
STRATEGY_MAP = STRATEGIES.stream().collect(Collectors.toMap(Strategy::strategy, s -> s));
|
|
}
|
|
|
|
@Override
|
|
public void execute(String strategy) {
|
|
STRATEGY_MAP.get(strategy).algorithm();
|
|
}
|
|
}
|
|
|