1 package com.github.mygreen.supercsv.localization;
2
3 import java.util.Objects;
4 import java.util.Optional;
5 import java.util.Properties;
6
7
8
9
10
11
12
13
14
15 public class PropertiesMessageResolver implements MessageResolver {
16
17 private Properties properties;
18
19
20
21
22
23 public PropertiesMessageResolver() {
24 this.properties = new Properties();
25 }
26
27
28
29
30
31
32 public PropertiesMessageResolver(final Properties properties) {
33 Objects.requireNonNull(properties, "properties should not be null.");
34
35 this.properties = properties;
36 }
37
38
39
40
41 @Override
42 public Optional<String> getMessage(final String code) {
43 return Optional.ofNullable(properties.getProperty(code));
44 }
45
46
47
48
49
50 public Properties getProperties() {
51 return properties;
52 }
53
54
55
56
57
58 public void setProperties(Properties properties) {
59 this.properties = properties;
60 }
61
62 }