Skip to content

Commit

Permalink
[MSHARED-1079] add build() method and document toString() method
Browse files Browse the repository at this point in the history
improve Javadoc
  • Loading branch information
kwin committed Jun 8, 2022
1 parent 412b279 commit 2dd9cf5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ public AnsiMessageBuilder format( String pattern, Object... args )

@Override
public String toString()
{
return build();
}

@Override
public String build()
{
return ansi.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

/**
* Message builder that supports configurable styling.
* An instance of this interface can be retrieved with {@link MessageUtils#buffer()}.
* After the message has been build with any of the append methods its content can be retrieved with {@link #build()}.
* @see MessageUtils
* @since 3.1.0
*/
Expand Down Expand Up @@ -130,4 +132,20 @@ public interface MessageBuilder
* @return the current builder
*/
MessageBuilder format( String pattern, Object... args );

/**
* Get the message constructed by this builder.
* The underlying buffer is not reset with this method, i.e. if you continue using this builder you just
* append content to the existing one.
* @return the message
* @since 4.0.0
*/
String build();

/**
* Same as {@link MessageBuilder#build()}.
* @deprecated Rather use {@link MessageBuilder#build()}
*/
@Deprecated
String toString();
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ public PlainMessageBuilder format( String pattern, Object... args )

@Override
public String toString()
{
return build();
}

@Override
public String build()
{
return buffer.toString();
}
Expand Down

0 comments on commit 2dd9cf5

Please sign in to comment.