1 package com.github.mygreen.cellformatter.lang;
2
3 import java.util.Collections;
4 import java.util.Map;
5 import java.util.Set;
6 import java.util.concurrent.ConcurrentHashMap;
7
8
9
10
11
12
13
14
15
16
17 public class MessageResource {
18
19
20
21
22
23 public static final MessageResourceessageResource.html#MessageResource">MessageResource NULL_OBJECT = new MessageResource() {
24
25 {
26 this.messages = Collections.unmodifiableMap(new ConcurrentHashMap<String, String>());
27
28 }
29
30 @Override
31 public boolean isNullObject() {
32 return true;
33 }
34 };
35
36
37
38
39
40
41 protected Map<String, String> messages;
42
43 public MessageResource() {
44 this.messages = new ConcurrentHashMap<>();
45 }
46
47
48
49
50
51
52 public String getMessage(final String key) {
53 return messages.get(key);
54 }
55
56
57
58
59
60 public Set<String> getKeys() {
61 return messages.keySet();
62 }
63
64
65
66
67
68
69 public void addMessage(final String key, final String message) {
70 messages.put(key, message);
71 }
72
73
74
75
76
77 public void addMessage(final MessageResource resource) {
78 this.messages.putAll(resource.messages);
79
80 }
81
82
83
84
85
86 public boolean isNullObject() {
87 return false;
88 }
89
90 }