Loading core/java/android/text/TextUtils.java +31 −22 Original line number Diff line number Diff line Loading @@ -297,38 +297,47 @@ public class TextUtils { /** * Returns a string containing the tokens joined by delimiters. * @param tokens an array objects to be joined. Strings will be formed from * the objects by calling object.toString(). * * @param delimiter a CharSequence that will be inserted between the tokens. If null, the string * "null" will be used as the delimiter. * @param tokens an array objects to be joined. Strings will be formed from the objects by * calling object.toString(). If tokens is null, a NullPointerException will be thrown. If * tokens is an empty array, an empty string will be returned. */ public static String join(CharSequence delimiter, Object[] tokens) { StringBuilder sb = new StringBuilder(); boolean firstTime = true; for (Object token: tokens) { if (firstTime) { firstTime = false; } else { sb.append(delimiter); public static String join(@NonNull CharSequence delimiter, @NonNull Object[] tokens) { final int length = tokens.length; if (length == 0) { return ""; } sb.append(token); final StringBuilder sb = new StringBuilder(); sb.append(tokens[0]); for (int i = 1; i < length; i++) { sb.append(delimiter); sb.append(tokens[i]); } return sb.toString(); } /** * Returns a string containing the tokens joined by delimiters. * @param tokens an array objects to be joined. Strings will be formed from * the objects by calling object.toString(). * * @param delimiter a CharSequence that will be inserted between the tokens. If null, the string * "null" will be used as the delimiter. * @param tokens an array objects to be joined. Strings will be formed from the objects by * calling object.toString(). If tokens is null, a NullPointerException will be thrown. If * tokens is empty, an empty string will be returned. */ public static String join(CharSequence delimiter, Iterable tokens) { StringBuilder sb = new StringBuilder(); Iterator<?> it = tokens.iterator(); if (it.hasNext()) { public static String join(@NonNull CharSequence delimiter, @NonNull Iterable tokens) { final Iterator<?> it = tokens.iterator(); if (!it.hasNext()) { return ""; } final StringBuilder sb = new StringBuilder(); sb.append(it.next()); while (it.hasNext()) { sb.append(delimiter); sb.append(it.next()); } } return sb.toString(); } Loading graphics/java/android/graphics/fonts/FontVariationAxis.java +1 −1 Original line number Diff line number Diff line Loading @@ -178,7 +178,7 @@ public final class FontVariationAxis { * @return String a valid font variation settings string. */ public static @NonNull String toFontVariationSettings(@Nullable FontVariationAxis[] axes) { if (axes == null || axes.length == 0) { if (axes == null) { return ""; } return TextUtils.join(",", axes); Loading Loading
core/java/android/text/TextUtils.java +31 −22 Original line number Diff line number Diff line Loading @@ -297,38 +297,47 @@ public class TextUtils { /** * Returns a string containing the tokens joined by delimiters. * @param tokens an array objects to be joined. Strings will be formed from * the objects by calling object.toString(). * * @param delimiter a CharSequence that will be inserted between the tokens. If null, the string * "null" will be used as the delimiter. * @param tokens an array objects to be joined. Strings will be formed from the objects by * calling object.toString(). If tokens is null, a NullPointerException will be thrown. If * tokens is an empty array, an empty string will be returned. */ public static String join(CharSequence delimiter, Object[] tokens) { StringBuilder sb = new StringBuilder(); boolean firstTime = true; for (Object token: tokens) { if (firstTime) { firstTime = false; } else { sb.append(delimiter); public static String join(@NonNull CharSequence delimiter, @NonNull Object[] tokens) { final int length = tokens.length; if (length == 0) { return ""; } sb.append(token); final StringBuilder sb = new StringBuilder(); sb.append(tokens[0]); for (int i = 1; i < length; i++) { sb.append(delimiter); sb.append(tokens[i]); } return sb.toString(); } /** * Returns a string containing the tokens joined by delimiters. * @param tokens an array objects to be joined. Strings will be formed from * the objects by calling object.toString(). * * @param delimiter a CharSequence that will be inserted between the tokens. If null, the string * "null" will be used as the delimiter. * @param tokens an array objects to be joined. Strings will be formed from the objects by * calling object.toString(). If tokens is null, a NullPointerException will be thrown. If * tokens is empty, an empty string will be returned. */ public static String join(CharSequence delimiter, Iterable tokens) { StringBuilder sb = new StringBuilder(); Iterator<?> it = tokens.iterator(); if (it.hasNext()) { public static String join(@NonNull CharSequence delimiter, @NonNull Iterable tokens) { final Iterator<?> it = tokens.iterator(); if (!it.hasNext()) { return ""; } final StringBuilder sb = new StringBuilder(); sb.append(it.next()); while (it.hasNext()) { sb.append(delimiter); sb.append(it.next()); } } return sb.toString(); } Loading
graphics/java/android/graphics/fonts/FontVariationAxis.java +1 −1 Original line number Diff line number Diff line Loading @@ -178,7 +178,7 @@ public final class FontVariationAxis { * @return String a valid font variation settings string. */ public static @NonNull String toFontVariationSettings(@Nullable FontVariationAxis[] axes) { if (axes == null || axes.length == 0) { if (axes == null) { return ""; } return TextUtils.join(",", axes); Loading