JoinerFunction: To stitch multiple objects into a string
SampleJoiner Joiner = Joiner.on (";"). Skipnulls (); Return Joiner.join (Bpeapplication, Pipeline, devicename, field);
Source Code /** * returns a joiner which automatically places {@code separator} between consecutive elements. */ public static joiner on (string separator) { return new joiner (separator); &NBSP;&NBSP} /** * Returns a string containing the string representation of each argument, using the previously * configured separator between each. */ public final string join (@Nullable object first, @Nullable object second, object... rest) { return Join (Iterable (first, second, rest)); &NBSP;&NBSP} public final string join (iterable<?> parts) {&Nbsp; return join (Parts.iterator ()); &NBSP;&NBSP} public final string join (iterator<?> parts) { return appendto (New stringbuilder (), parts). toString (); &NBSP;&NBSP} public final string join (iterator<?> parts) { return appendto (New stringbuilder (), parts). toString (); &NBSP;&NBSP} public <a extends appendable> a appendto (A Appendable, iterator<?> parts) throws ioexception { Checknotnull (appendable); if (Parts.hasnext ()) { appendable.append ( ToString (Parts.next ())); while (Parts.hasnext ()) { appendable.append (separator); &nBsp; appendable.append (ToString (Parts.next ())); } return appendable; }
SplitterThe splitter provides joiner corresponding functionality.
SampleSplitter.on (', '). Split ("Foo,bar") returns: This invocation returns a iterable<string> containing "foo" and "Bar", in That order.
By default Splitter ' s behavior be very simplistic:Splitter.on (', '). Split ("Foo,,bar, Quux") This returns a iterable C ontaining ["foo", "" "," Bar "," Quux "]. Notice that "Splitter does not assume" you want empty strings the removed, or that you wish to trim whitespace. If you are want features like this, simply ask for them:
Private Static FinalSplitter my_splitter = Splitter.on (', ')
. Trimresults ()
. Omitemptystrings (); Now My_splitter.split ("foo,, Bar, Quux,") returns a iterable containing just ["foo", "Bar", "Quux"]. The order of the "which" configuration methods are called is never significant; For instance, trimming is always applied a before for a checking result, empty of the "order in regardless" t Rimresults () and Omitemptystrings () methods were invoked. &N Bsp