-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathI18nMsg.java
More file actions
42 lines (33 loc) · 1.02 KB
/
I18nMsg.java
File metadata and controls
42 lines (33 loc) · 1.02 KB
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
package graphql.i18n;
import java.util.ArrayList;
import java.util.List;
import static java.util.Arrays.asList;
/**
* A class that represents the intention to create a I18n message
*/
public class I18nMsg {
private final String msgKey;
private final List<Object> msgArguments;
public I18nMsg(String msgKey, List<Object> msgArguments) {
this.msgKey = msgKey;
this.msgArguments = msgArguments;
}
public I18nMsg(String msgKey, Object... msgArguments) {
this.msgKey = msgKey;
this.msgArguments = asList(msgArguments);
}
public String getMsgKey() {
return msgKey;
}
public Object[] getMsgArguments() {
return msgArguments.toArray();
}
public I18nMsg addArgumentAt(int index, Object argument) {
List<Object> newArgs = new ArrayList<>(this.msgArguments);
newArgs.add(index, argument);
return new I18nMsg(this.msgKey, newArgs);
}
public String toI18n(I18n i18n) {
return i18n.msg(msgKey, msgArguments);
}
}