1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package be.objectify.led;
17
18 import be.objectify.led.util.ContractUtils;
19 import be.objectify.led.util.StringUtils;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 import java.util.Properties;
24
25
26
27
28
29
30 public class DefaultPropertyContext implements PropertyContext
31 {
32 private static final Logger LOGGER = LoggerFactory.getLogger(DefaultPropertyContext.class);
33
34 private final Properties properties = new Properties();
35
36 public DefaultPropertyContext(Properties... properties)
37 {
38 ContractUtils.nonNull(properties, "properties");
39
40 for (Properties propertiesInstance : properties)
41 {
42 this.properties.putAll(propertiesInstance);
43 }
44 }
45
46
47 public String getValue(String propertyName)
48 {
49 String value = null;
50
51 if (properties.containsKey(propertyName))
52 {
53 value = properties.getProperty(propertyName);
54 }
55
56 String property = System.getProperty(propertyName);
57 if (!StringUtils.isEmpty(property))
58 {
59 value = property;
60 }
61
62 if (value != null)
63 {
64 LOGGER.debug("Found value [{}] for property [{}]",
65 value,
66 propertyName);
67 }
68
69 return value;
70 }
71 }