|
@@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
@Component
|
|
|
@Slf4j
|
|
@@ -14,17 +15,13 @@ public class StrategyIndexScoreWeightService {
|
|
|
private Map<String, Map<String, Map<String, Double>>> strategyIndexScoreWeightMap;
|
|
|
|
|
|
public double getWeight(String strategy, Integer index, String score) {
|
|
|
+ Double weight = 1.0;
|
|
|
Map<String, Map<String, Double>> indexMap = strategyIndexScoreWeightMap.get(strategy);
|
|
|
- if (indexMap == null) {
|
|
|
- return 1.0;
|
|
|
- }
|
|
|
- Map<String, Double> scoreMap = indexMap.get(String.valueOf(index));
|
|
|
- if (scoreMap == null) {
|
|
|
- return 1.0;
|
|
|
- }
|
|
|
- Double weight = scoreMap.get(score);
|
|
|
- if (weight == null) {
|
|
|
- return 1.0;
|
|
|
+ if (Objects.nonNull(indexMap)) {
|
|
|
+ Map<String, Double> scoreMap = indexMap.get(String.valueOf(index));
|
|
|
+ if (Objects.nonNull(scoreMap) && scoreMap.containsKey(score)) {
|
|
|
+ weight = scoreMap.get(score);
|
|
|
+ }
|
|
|
}
|
|
|
return weight;
|
|
|
}
|