src/share/classes/java/util/StringJoiner.java

Print this page
rev 7727 : 8020539: Clean up doclint problems in java.util package, part 2
Summary: Clean up doclint errors and warnings in classes in java.util
Reviewed-by: darcy,chegar
Contributed-by: Brian Burkhalter <brian.burkhalter@oracle.com>


 185         return this;
 186     }
 187 
 188     /**
 189      * Adds the contents of the given {@code StringJoiner} without prefix and
 190      * suffix as the next element if it is non-empty. If the given {@code
 191      * StringJoiner} is empty, the call has no effect.
 192      *
 193      * <p>A {@code StringJoiner} is empty if {@link #add(CharSequence) add()}
 194      * has never been called, and if {@code merge()} has never been called
 195      * with a non-empty {@code StringJoiner} argument.
 196      *
 197      * <p>If the other {@code StringJoiner} is using a different delimiter,
 198      * then elements from the other {@code StringJoiner} are concatenated with
 199      * that delimiter and the result is appended to this {@code StringJoiner}
 200      * as a single element.
 201      *
 202      * @param other The {@code StringJoiner} whose contents should be merged
 203      *              into this one
 204      * @throws NullPointerException if the other {@code StringJoiner} is null

 205      */
 206     public StringJoiner merge(StringJoiner other) {
 207         Objects.requireNonNull(other);
 208         if (other.value != null) {
 209             StringBuilder builder = prepareBuilder();
 210             StringBuilder otherBuilder = other.value;
 211             if (other.prefix.length() < otherBuilder.length()) {
 212                 builder.append(otherBuilder, other.prefix.length(), otherBuilder.length());
 213             }
 214         }
 215         return this;
 216     }
 217 
 218     private StringBuilder prepareBuilder() {
 219         if (value != null) {
 220             value.append(delimiter);
 221         } else {
 222             value = new StringBuilder().append(prefix);
 223         }
 224         return value;


 185         return this;
 186     }
 187 
 188     /**
 189      * Adds the contents of the given {@code StringJoiner} without prefix and
 190      * suffix as the next element if it is non-empty. If the given {@code
 191      * StringJoiner} is empty, the call has no effect.
 192      *
 193      * <p>A {@code StringJoiner} is empty if {@link #add(CharSequence) add()}
 194      * has never been called, and if {@code merge()} has never been called
 195      * with a non-empty {@code StringJoiner} argument.
 196      *
 197      * <p>If the other {@code StringJoiner} is using a different delimiter,
 198      * then elements from the other {@code StringJoiner} are concatenated with
 199      * that delimiter and the result is appended to this {@code StringJoiner}
 200      * as a single element.
 201      *
 202      * @param other The {@code StringJoiner} whose contents should be merged
 203      *              into this one
 204      * @throws NullPointerException if the other {@code StringJoiner} is null
 205      * @return This {@code StringJoiner}
 206      */
 207     public StringJoiner merge(StringJoiner other) {
 208         Objects.requireNonNull(other);
 209         if (other.value != null) {
 210             StringBuilder builder = prepareBuilder();
 211             StringBuilder otherBuilder = other.value;
 212             if (other.prefix.length() < otherBuilder.length()) {
 213                 builder.append(otherBuilder, other.prefix.length(), otherBuilder.length());
 214             }
 215         }
 216         return this;
 217     }
 218 
 219     private StringBuilder prepareBuilder() {
 220         if (value != null) {
 221             value.append(delimiter);
 222         } else {
 223             value = new StringBuilder().append(prefix);
 224         }
 225         return value;