Returns a joiner with the same behavior as this one, except automatically substituting {@code nullText} for any provided null elements.
(String nullText)
| 274 | * nullText} for any provided null elements. |
| 275 | */ |
| 276 | public Joiner useForNull(String nullText) { |
| 277 | checkNotNull(nullText); |
| 278 | return new Joiner(this) { |
| 279 | @Override |
| 280 | CharSequence toString(@Nullable Object part) { |
| 281 | return (part == null) ? nullText : Joiner.this.toString(part); |
| 282 | } |
| 283 | |
| 284 | @Override |
| 285 | public Joiner useForNull(String nullText) { |
| 286 | throw new UnsupportedOperationException("already specified useForNull"); |
| 287 | } |
| 288 | |
| 289 | @Override |
| 290 | public Joiner skipNulls() { |
| 291 | throw new UnsupportedOperationException("already specified useForNull"); |
| 292 | } |
| 293 | }; |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * Returns a joiner with the same behavior as this joiner, except automatically skipping over any |