Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String format(String input, PrematchMatch prematchMatch,
- Map<String, String> specifiers) {
- Matcher matcher = SPECIFIER_PATTERN.matcher(input);
- List<String> partsToReplace = new ArrayList<>();
- while (matcher.find()) {
- partsToReplace.add(matcher.group());
- }
- if (partsToReplace.size() > 0) {
- for (String partToReplace : partsToReplace) {
- if (partToReplace != null && partToReplace.length() > 0) {
- switch (partToReplace) {
- case TEAM_1_SPECIFIER:
- input = input.replace(partToReplace, prematchMatch.getTeam1Name());
- break;
- case TEAM_2_SPECIFIER:
- input = input.replace(partToReplace, prematchMatch.getTeam2Name());
- break;
- default:
- String specifierKey = partToReplace.replaceAll("[^a-zA-Z0-9]", "");
- String prefix = getPrefixForPart(partToReplace);
- String sufix = getSufixForPart(partToReplace);
- if (!specifierKey.isEmpty() && specifiers.containsKey(specifierKey)) {
- String specifierValue = calculateSpecifierValueWithPrefix(specifiers.get(specifierKey), prefix);
- input = input.replace(partToReplace, (specifierValue + sufix));
- }
- break;
- }
- }
- }
- }
- return input;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement