Skip to content

Commit

Permalink
[MSHARED-1079] Improve Javadoc of MessageBuilder and deprecate #toStr…
Browse files Browse the repository at this point in the history
…ing()

This closes #96
  • Loading branch information
kwin authored and michael-o committed Jul 25, 2022
1 parent 8822bea commit 9b0e667
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
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 @@ -19,8 +19,13 @@
* under the License.
*/

import java.util.Formatter;

/**
* Message builder that supports configurable styling.
* An instance of this interface can be retrieved with {@link MessageUtils#buffer()}.
* After the message has been constructed with any of the append methods its content can be retrieved
* with {@link #build()}.
* @see MessageUtils
* @since 3.1.0
*/
Expand Down Expand Up @@ -125,9 +130,25 @@ public interface MessageBuilder
/**
* Append formatted content to the buffer.
* @see String#format(String, Object...)
* @param pattern a <a href="../util/Formatter.html#syntax">format string</a>
* @param pattern a format string according to the {@link Formatter} syntax
* @param args arguments referenced by the format specifiers in the format string.
* @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 9b0e667

Please sign in to comment.