1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.property.processor;
17
18 import java.util.List;
19 import java.util.Properties;
20
21 import org.kuali.common.util.Mode;
22 import org.kuali.common.util.PropertyUtils;
23 import org.kuali.common.util.property.Constants;
24
25 public class OverrideProcessor implements PropertyProcessor {
26
27 Mode propertyOverwriteMode;
28 Properties overrideProperties;
29 List<String> includes;
30 List<String> excludes;
31
32 public OverrideProcessor() {
33 this(Constants.DEFAULT_PROPERTY_OVERWRITE_MODE);
34 }
35
36 public OverrideProcessor(Mode propertyOverwriteMode) {
37 this(Constants.DEFAULT_PROPERTY_OVERWRITE_MODE, null);
38 }
39
40 public OverrideProcessor(Mode propertyOverwriteMode, Properties overrideProperties) {
41 super();
42 this.propertyOverwriteMode = propertyOverwriteMode;
43 this.overrideProperties = overrideProperties;
44 }
45
46 @Override
47 public void process(Properties properties) {
48 List<String> keys = PropertyUtils.getSortedKeys(overrideProperties, includes, excludes);
49 for (String key : keys) {
50 String newValue = overrideProperties.getProperty(key);
51 PropertyUtils.addOrOverrideProperty(properties, key, newValue, propertyOverwriteMode);
52 }
53 }
54
55 public Mode getPropertyOverwriteMode() {
56 return propertyOverwriteMode;
57 }
58
59 public void setPropertyOverwriteMode(Mode propertyOverwriteMode) {
60 this.propertyOverwriteMode = propertyOverwriteMode;
61 }
62
63 public Properties getOverrideProperties() {
64 return overrideProperties;
65 }
66
67 public void setOverrideProperties(Properties overrideProperties) {
68 this.overrideProperties = overrideProperties;
69 }
70
71 public List<String> getIncludes() {
72 return includes;
73 }
74
75 public void setIncludes(List<String> includes) {
76 this.includes = includes;
77 }
78
79 public List<String> getExcludes() {
80 return excludes;
81 }
82
83 public void setExcludes(List<String> excludes) {
84 this.excludes = excludes;
85 }
86
87 }