commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: [lang] StrBuilder append(String, Object...)
Date Sat, 22 Sep 2012 19:31:47 GMT
Actually that "if" should not even be there ;)

Gary

On Fri, Sep 21, 2012 at 2:50 PM, Bruno P. Kinoshita <
brunodepaulak@yahoo.com.br> wrote:

> +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 <simonetripodi@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 <garydgregory@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: garydgregory@gmail.com | ggregory@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-unsubscribe@commons.apache.org
> >For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message