-
Notifications
You must be signed in to change notification settings - Fork 11.1k
refactor(Joiner): rename internal toString helper to toCharSequence #8519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,10 +104,10 @@ public <A extends Appendable> A appendTo(A appendable, Iterable<?> parts) throws | |
| public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws IOException { | ||
| checkNotNull(appendable); | ||
| if (parts.hasNext()) { | ||
| appendable.append(toString(parts.next())); | ||
| appendable.append(toCharSequence(parts.next())); | ||
| while (parts.hasNext()) { | ||
| appendable.append(separator); | ||
| appendable.append(toString(parts.next())); | ||
| appendable.append(toCharSequence(parts.next())); | ||
| } | ||
| } | ||
| return appendable; | ||
|
|
@@ -221,7 +221,7 @@ public String join(Iterable<?> parts) { | |
| */ | ||
| toJoin = Arrays.copyOf(toJoin, expandedCapacity(toJoin.length, toJoin.length + 1)); | ||
| } | ||
| toJoin[i++] = toString(part); | ||
| toJoin[i++] = toCharSequence(part); | ||
| } | ||
| // We might not have seen the expected number of elements, as discussed above. | ||
| if (i != toJoin.length) { | ||
|
|
@@ -277,8 +277,8 @@ public Joiner useForNull(String nullText) { | |
| checkNotNull(nullText); | ||
| return new Joiner(this) { | ||
| @Override | ||
| CharSequence toString(@Nullable Object part) { | ||
| return (part == null) ? nullText : Joiner.this.toString(part); | ||
| CharSequence toCharSequence(@Nullable Object part) { | ||
| return (part == null) ? nullText : Joiner.this.toCharSequence(part); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -312,15 +312,15 @@ public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws | |
| while (parts.hasNext()) { | ||
| Object part = parts.next(); | ||
| if (part != null) { | ||
| appendable.append(Joiner.this.toString(part)); | ||
| appendable.append(Joiner.this.toCharSequence(part)); | ||
| break; | ||
| } | ||
| } | ||
| while (parts.hasNext()) { | ||
| Object part = parts.next(); | ||
| if (part != null) { | ||
| appendable.append(separator); | ||
| appendable.append(Joiner.this.toString(part)); | ||
| appendable.append(Joiner.this.toCharSequence(part)); | ||
| } | ||
| } | ||
| return appendable; | ||
|
|
@@ -426,15 +426,15 @@ public <A extends Appendable> A appendTo(A appendable, Iterator<? extends Entry< | |
| checkNotNull(appendable); | ||
| if (parts.hasNext()) { | ||
| Entry<?, ?> entry = parts.next(); | ||
| appendable.append(joiner.toString(entry.getKey())); | ||
| appendable.append(joiner.toCharSequence(entry.getKey())); | ||
| appendable.append(keyValueSeparator); | ||
| appendable.append(joiner.toString(entry.getValue())); | ||
| appendable.append(joiner.toCharSequence(entry.getValue())); | ||
| while (parts.hasNext()) { | ||
| appendable.append(joiner.separator); | ||
| Entry<?, ?> e = parts.next(); | ||
| appendable.append(joiner.toString(e.getKey())); | ||
| appendable.append(joiner.toCharSequence(e.getKey())); | ||
| appendable.append(keyValueSeparator); | ||
| appendable.append(joiner.toString(e.getValue())); | ||
| appendable.append(joiner.toCharSequence(e.getValue())); | ||
| } | ||
| } | ||
| return appendable; | ||
|
|
@@ -506,8 +506,7 @@ public MapJoiner useForNull(String nullText) { | |
| } | ||
| } | ||
|
|
||
| // TODO(cpovirk): Rename to "toCharSequence." | ||
| CharSequence toString(@Nullable Object part) { | ||
| CharSequence toCharSequence(@Nullable Object part) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment block further down in this method (around line 524) still references the old name:
Since this PR renames the method, it would be good to update that mention to |
||
| /* | ||
| * requireNonNull is not safe: Joiner.on(...).join(somethingThatContainsNull) will indeed throw. | ||
| * However, Joiner.on(...).useForNull(...).join(somethingThatContainsNull) *is* safe -- because | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as in the JRE flavor: the comment block further down in this method (around line 488) still says
toString(Object)and should be updated totoCharSequence(Object)as part of this rename.