RecommendationAlgorithmConfigurationImpl.java
3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.cq.targetrecommendations.impl.model;
import com.adobe.cq.targetrecommendations.api.model.DayCountInterval;
import com.adobe.cq.targetrecommendations.api.model.RecommendationAlgorithmConfiguration;
import com.adobe.cq.targetrecommendations.api.model.RecommendationAlgorithmInclusionRule;
import java.util.List;
import java.util.Map;
public class RecommendationAlgorithmConfigurationImpl
implements RecommendationAlgorithmConfiguration {
private Map<Object, Object> properties;
public RecommendationAlgorithmConfigurationImpl(Map<Object, Object> properties) {
this.properties = properties;
}
@Override
public String getConfigurationKey() {
return this.getProperty((Object)AlgorightmConfigurationProperty.KEY, String.class);
}
@Override
public String getConfigurationType() {
return this.getProperty((Object)AlgorightmConfigurationProperty.TYPE, String.class);
}
@Override
public String getConfigurationDataSource() {
return this.getProperty((Object)AlgorightmConfigurationProperty.DATASOURCE, String.class);
}
@Override
public String getConfigurationAttribute() {
return this.getProperty((Object)AlgorightmConfigurationProperty.ATTRIBUTE, String.class);
}
@Override
public DayCountInterval getDayCount() {
String dayCountStr = this.getProperty((Object)AlgorightmConfigurationProperty.DAY_COUNT, String.class);
return DayCountInterval.fromString(dayCountStr);
}
@Override
public double getPriceRangeMin() {
return this.getProperty((Object)AlgorightmConfigurationProperty.PRICE_MIN, Double.class);
}
@Override
public double getPriceRangeMax() {
return this.getProperty((Object)AlgorightmConfigurationProperty.PRICE_MAX, Double.class);
}
@Override
public String getProductConfidence() {
return this.getProperty((Object)AlgorightmConfigurationProperty.PRODUCT_CONFIDENCE, String.class);
}
@Override
public int getMinInventory() {
return this.getProperty((Object)AlgorightmConfigurationProperty.PRODUCT_MIN_INVENTORY, Integer.class);
}
@Override
public List<RecommendationAlgorithmInclusionRule> getInclusionRules() {
return this.getProperty((Object)AlgorightmConfigurationProperty.INCLUSION_RULES, List.class);
}
private <T> T getProperty(Object key, Class<T> convertTo) {
Object propValue = this.properties.get(key);
T convertedPropValue = null;
if (propValue != null && convertTo.isAssignableFrom(propValue.getClass())) {
convertedPropValue = convertTo.cast(propValue);
}
return convertedPropValue;
}
public static enum AlgorightmConfigurationProperty {
KEY,
TYPE,
DATASOURCE,
ATTRIBUTE,
DAY_COUNT,
PRICE_MIN,
PRICE_MAX,
PRODUCT_CONFIDENCE,
PRODUCT_MIN_INVENTORY,
INCLUSION_RULES;
private AlgorightmConfigurationProperty() {
}
}
}