Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSHARED-1079] add build() method and document toString() method #96

Merged
merged 1 commit into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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