Initial commit
This commit is contained in:
82
sources/com/google/common/base/Joiner.java
Normal file
82
sources/com/google/common/base/Joiner.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package com.google.common.base;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Joiner {
|
||||
private final String a;
|
||||
|
||||
public static Joiner a(char c) {
|
||||
return new Joiner(String.valueOf(c));
|
||||
}
|
||||
|
||||
public static Joiner b(String str) {
|
||||
return new Joiner(str);
|
||||
}
|
||||
|
||||
private Joiner(String str) {
|
||||
Preconditions.a(str);
|
||||
this.a = str;
|
||||
}
|
||||
|
||||
public <A extends Appendable> A a(A a, Iterator<?> it) throws IOException {
|
||||
Preconditions.a(a);
|
||||
if (it.hasNext()) {
|
||||
a.append(a(it.next()));
|
||||
while (it.hasNext()) {
|
||||
a.append(this.a);
|
||||
a.append(a(it.next()));
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private Joiner(Joiner joiner) {
|
||||
this.a = joiner.a;
|
||||
}
|
||||
|
||||
public final StringBuilder a(StringBuilder sb, Iterator<?> it) {
|
||||
try {
|
||||
a((Joiner) sb, it);
|
||||
return sb;
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public final String a(Iterable<?> iterable) {
|
||||
return a(iterable.iterator());
|
||||
}
|
||||
|
||||
public final String a(Iterator<?> it) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
a(sb, it);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public final String a(Object[] objArr) {
|
||||
return a((Iterable<?>) Arrays.asList(objArr));
|
||||
}
|
||||
|
||||
public Joiner a(final String str) {
|
||||
Preconditions.a(str);
|
||||
return new Joiner(this) { // from class: com.google.common.base.Joiner.1
|
||||
@Override // com.google.common.base.Joiner
|
||||
CharSequence a(Object obj) {
|
||||
return obj == null ? str : Joiner.this.a(obj);
|
||||
}
|
||||
|
||||
@Override // com.google.common.base.Joiner
|
||||
public Joiner a(String str2) {
|
||||
throw new UnsupportedOperationException("already specified useForNull");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
CharSequence a(Object obj) {
|
||||
Preconditions.a(obj);
|
||||
return obj instanceof CharSequence ? (CharSequence) obj : obj.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user