Skip to content

Commit 89a92a1

Browse files
committed
rename TextFormatter#ERROR to error to match other factory methods
1 parent 17bafef commit 89a92a1

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/main/java/textFormatter/TextFormatter.java

+22-5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ public static TextFormatter of(@NotNull String contents, @NotNull Color foregrou
7777
return TextFormatter.of(contents).withForegroundColor(foreground);
7878
}
7979

80+
/**
81+
* Creates a new {@link TextFormatter} with the specified contents and colors.
82+
* @param contents The contents of the formatter.
83+
* @param foreground The foreground color of the formatter.
84+
* @param background The background color of the formatter.
85+
*/
86+
public static TextFormatter of(@NotNull String contents, @NotNull Color foreground, @NotNull Color background) {
87+
return TextFormatter.of(contents).withColors(foreground, background);
88+
}
89+
8090
/**
8191
* Creates a new {@link TextFormatter} with empty contents.
8292
* @return a new {@link TextFormatter} with empty contents
@@ -85,6 +95,18 @@ public static TextFormatter create() {
8595
return new TextFormatter("");
8696
}
8797

98+
/**
99+
* Returns a new {@link TextFormatter} with the specified contents and the error formatting.
100+
* <p>
101+
* The error formatting is a bold, black text with a bright red background.
102+
* @param msg The contents of the formatter.
103+
* @return a new {@link TextFormatter} with the specified contents and the error formatting
104+
* */
105+
public static @NotNull TextFormatter error(@NotNull String msg) {
106+
return TextFormatter.of(msg, Color.BLACK, Color.BRIGHT_RED).addFormat(FormatOption.BOLD);
107+
}
108+
109+
88110
/**
89111
* Adds the specified formatting options to the formatter.
90112
* @param options The formatting options to add.
@@ -336,11 +358,6 @@ else if (TextFormatter.startWithDefaultColorIfNotDefined && this.parent == null)
336358
return buff.toString();
337359
}
338360

339-
/** Returns a template for a {@link TextFormatter} that is used for errors */
340-
public static @NotNull TextFormatter ERROR(@NotNull String msg) {
341-
return TextFormatter.of(msg, Color.BRIGHT_RED).addFormat(FormatOption.REVERSE, FormatOption.BOLD);
342-
}
343-
344361
/**
345362
* Returns a string with a terminal sequence with the specified code.
346363
* (e.g. {@code "ESC[<code here>m"})

0 commit comments

Comments
 (0)