-
Notifications
You must be signed in to change notification settings - Fork 276
/
Copy pathRulesPropertiesImpl.java
43 lines (36 loc) · 1.46 KB
/
RulesPropertiesImpl.java
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
package io.apicurio.registry.rules;
import io.apicurio.registry.storage.dto.RuleConfigurationDto;
import io.apicurio.registry.types.RuleType;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;
public class RulesPropertiesImpl implements RulesProperties {
@SuppressWarnings("unused")
private final Properties properties;
private final Map<RuleType, String> defaultGlobalRules;
public RulesPropertiesImpl(Properties properties) {
this.properties = properties;
this.defaultGlobalRules = properties.stringPropertyNames().stream()
.collect(Collectors.toMap(
rulePropertyName -> RuleType.fromValue(rulePropertyName.toUpperCase()),
properties::getProperty));
}
@Override
public Set<RuleType> getDefaultGlobalRules() {
return defaultGlobalRules.keySet();
}
@Override
public boolean isDefaultGlobalRuleConfigured(RuleType ruleType) {
return defaultGlobalRules.containsKey(ruleType);
}
@Override
public RuleConfigurationDto getDefaultGlobalRuleConfiguration(RuleType ruleType) {
RuleConfigurationDto ruleConfigurationDto = null;
if (defaultGlobalRules.containsKey(ruleType)) {
ruleConfigurationDto = new RuleConfigurationDto();
ruleConfigurationDto.setConfiguration(defaultGlobalRules.get(ruleType));
}
return ruleConfigurationDto;
}
}