Initial commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package com.alttd.templates;
|
||||
|
||||
public class Parser {
|
||||
public static String parse(String message, Template... templates) {
|
||||
for (Template template : templates) {
|
||||
message = template.apply(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.alttd.templates;
|
||||
|
||||
public class Template {
|
||||
|
||||
private final String key;
|
||||
private final String replacement;
|
||||
|
||||
private Template(String key, String replacement) {
|
||||
this.key = key;
|
||||
this.replacement = replacement;
|
||||
}
|
||||
|
||||
public static Template of(String key, String replacement) {
|
||||
return new Template("<" + key + ">", replacement);
|
||||
}
|
||||
|
||||
protected String apply(String string) {
|
||||
return string.replaceAll(key, replacement);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user