+1 as well Gary, and if you want to test the "if (objs == null) {", then you 
just have to add something similar to: 

sb.append("Hi", (Object[])null);

And then check the result.

Cheers


Bruno P. Kinoshita
http://kinoshita.eti.br
http://tupilabs.com


>________________________________
> From: Simone Tripodi <simonetrip...@apache.org>
>To: Commons Developers List <dev@commons.apache.org> 
>Sent: Friday, 21 September 2012 4:54 AM
>Subject: Re: [lang] StrBuilder append(String, Object...)
> 
>+1 very well thought, Gary!
>
>even if StrBuilder would look like java.util.Formatter, I think that
>this is a nice addition.
>
>best,
>-Simo
>
>http://people.apache.org/~simonetripodi/
>http://simonetripodi.livejournal.com/
>http://twitter.com/simonetripodi
>http://www.99soft.org/
>
>
>On Thu, Sep 20, 2012 at 11:12 PM, Gary Gregory <garydgreg...@gmail.com> wrote:
>> I just wrote this up for a different project and it seems like a nice add
>> for StrBuilder:
>>
>>     @Test
>>     public void testAppendFormatted_Object() {
>>         StrBuilder sb;
>>
>>         sb = new StrBuilder();
>>         sb.append("Hi", "Alice");
>>         assertEquals("Hi", sb.toString());
>>
>>         sb = new StrBuilder();
>>         sb.append("Hi %s", "Alice");
>>         assertEquals("Hi Alice", sb.toString());
>>
>>         sb = new StrBuilder();
>>         sb.append("Hi %s %,d", "Alice", 5000);
>>         assertEquals("Hi Alice 5,000", sb.toString());
>>     }
>>
>>     /**
>>      * Appends an formatted string to this string builder.
>>      * Appending null will call {@link #appendNull()}.
>>      *
>>      * @param format  the format string, see {@link String#format(String,
>> Object...)}
>>      * @param objs  the objects to use in the format string
>>      * @return this, to enable chaining
>>      */
>>     public StrBuilder append(String format, Object... objs) {
>>         if (objs == null) {
>>             return appendNull();
>>         }
>>         return append(String.format(format, objs));
>>     }
>>
>> Thoughts?
>>
>>
>> --
>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
>> JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
>> Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>For additional commands, e-mail: dev-h...@commons.apache.org
>
>
>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to