Skip to content

Commit 954604c

Browse files
committed
Make builder return the standard instance
1 parent bdc5a73 commit 954604c

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

inkymessage/src/main/java/ink/glowing/text/InkyMessage.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public sealed interface InkyMessage extends ComponentSerializer<Component, Compo
5454
* Creates new instance of InkyMessage with the provided style ink.
5555
* @param ink style ink to use
5656
* @return the new instance
57+
* @see InkyMessage#builder()
5758
*/
5859
@Contract(value = "_, _ -> new", pure = true)
5960
static @NotNull InkyMessage inkyMessage(char reset, @NotNull Ink ink) {
@@ -64,6 +65,7 @@ public sealed interface InkyMessage extends ComponentSerializer<Component, Compo
6465
* Creates new instance of InkyMessage with the provided style ink.
6566
* @param inks style inks to use
6667
* @return the new instance
68+
* @see InkyMessage#builder()
6769
*/
6870
@Contract(value = "_, _ -> new", pure = true)
6971
static @NotNull InkyMessage inkyMessage(char reset, @NotNull Ink @NotNull ... inks) {
@@ -74,6 +76,7 @@ public sealed interface InkyMessage extends ComponentSerializer<Component, Compo
7476
* Creates new instance of InkyMessage with the provided style ink.
7577
* @param inks style inks to use
7678
* @return the new instance
79+
* @see InkyMessage#builder()
7780
*/
7881
@Contract(value = "_, _ -> new", pure = true)
7982
static @NotNull InkyMessage inkyMessage(char reset, @NotNull Iterable<? extends @NotNull Ink> inks) {
@@ -426,14 +429,24 @@ static boolean isNotSpecial(char ch) {
426429
}
427430

428431
/**
429-
* Creates a new InkyMessage builder.
432+
* Creates a new empty InkyMessage builder.
430433
* @return a builder
431434
*/
432435
@Contract(value = "-> new", pure = true)
433-
static @NotNull InkyMessage.Builder builder() {
436+
static @NotNull InkyMessage.Builder emptyBuilder() {
434437
return new Builder();
435438
}
436439

440+
/**
441+
* Creates a new InkyMessage builder using standard {@link Ink}s.
442+
* @return a builder
443+
* @see InkyMessage#inkyMessage()
444+
*/
445+
@Contract(value = "-> new", pure = true)
446+
static @NotNull InkyMessage.Builder builder() {
447+
return InkyMessageImpl.STANDARD.toBuilder();
448+
}
449+
437450
class Builder implements AbstractBuilder<InkyMessage> {
438451
private Map<String, Modifier> modifiers;
439452
private Map<String, Placeholder> placeholders;

inkymessage/src/main/java/ink/glowing/text/InkyMessageImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import static java.util.Collections.unmodifiableMap;
3131

3232
final class InkyMessageImpl implements InkyMessage {
33-
static final InkyMessage STANDARD = InkyMessage.builder()
33+
static final InkyMessage STANDARD = InkyMessage.emptyBuilder()
3434
.addPlaceholder(newlinePlaceholder())
3535
.addModifiers(standardModifiers())
3636
.addSymbolics(notchianFormat())

0 commit comments

Comments
 (0)