Skip to content

Commit a2ff1a4

Browse files
author
lorenzo
committed
code
1 parent 6b8714a commit a2ff1a4

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed
Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
11
package com.reedelk.file.internal.commons;
22

3+
import com.reedelk.runtime.api.commons.FormattedMessage;
4+
35
public class Messages {
46

57
private Messages() {
68
}
79

8-
private static String formatMessage(String template, Object ...args) {
9-
return String.format(template, args);
10-
}
11-
12-
interface FormattedMessage {
13-
String format(Object ...args);
14-
}
15-
1610
public enum FileReadComponent implements FormattedMessage {
1711

1812
FILE_NAME_ERROR("Could not evaluate file with with name=[%s]"),
1913
FILE_IS_DIRECTORY("Could not read file=[%s]: is a directory"),
2014
FILE_LOCK_ERROR("Could not acquire lock on file=[%s]: %s"),
2115
FILE_READ_ERROR("Could not read file=[%s]: %s");
2216

23-
private String msg;
17+
private String message;
2418

25-
FileReadComponent(String msg) {
26-
this.msg = msg;
19+
FileReadComponent(String message) {
20+
this.message = message;
2721
}
2822

2923
@Override
30-
public String format(Object... args) {
31-
return formatMessage(msg, args);
24+
public String template() {
25+
return message;
3226
}
3327
}
3428

@@ -39,17 +33,16 @@ public enum FileWriteComponent implements FormattedMessage {
3933
ERROR_FILE_WRITE_WITH_PATH("Could not write file with path=[%s]: %s"),
4034
ERROR_FILE_WRITE("Could not write file: %s");
4135

42-
private String msg;
36+
private String message;
4337

44-
FileWriteComponent(String msg) {
45-
this.msg = msg;
38+
FileWriteComponent(String message) {
39+
this.message = message;
4640
}
4741

4842
@Override
49-
public String format(Object... args) {
50-
return formatMessage(msg, args);
43+
public String template() {
44+
return message;
5145
}
52-
5346
}
5447

5548
public enum Misc implements FormattedMessage {
@@ -58,16 +51,15 @@ public enum Misc implements FormattedMessage {
5851
FILE_LOCK_MAX_RETRY_ERROR("Could not acquire lock on file=[%s]: %s"),
5952
MAX_ATTEMPTS_EXCEEDED("Max retry attempts (%d) exceeded");
6053

61-
private String msg;
54+
private String message;
6255

63-
Misc(String msg) {
64-
this.msg = msg;
56+
Misc(String message) {
57+
this.message = message;
6558
}
6659

6760
@Override
68-
public String format(Object... args) {
69-
return formatMessage(msg, args);
61+
public String template() {
62+
return message;
7063
}
71-
7264
}
7365
}

0 commit comments

Comments
 (0)