Class Joiner
java.lang.Object
cloud.opencode.base.string.builder.Joiner
String Joiner (Guava Style)
字符串连接器(Guava风格)
Joins pieces of text with a separator. Thread-safe and immutable.
使用分隔符连接文本片段。线程安全且不可变。
Features | 主要功能:
- Flexible null handling - 灵活的null处理
- Map joining support - Map连接支持
- Append to existing builders - 追加到现有构建器
- Immutable, thread-safe - 不可变,线程安全
Usage Examples | 使用示例:
// Basic join
String result = Joiner.on(", ").join(Arrays.asList("a", "b", "c"));
// -> "a, b, c"
// Skip nulls
String safe = Joiner.on(", ").skipNulls().join("a", null, "c");
// -> "a, c"
// Replace nulls
String withDefault = Joiner.on(", ").useForNull("N/A").join("a", null, "c");
// -> "a, N/A, c"
// Join Map
String params = Joiner.on("&").withKeyValueSeparator("=")
.join(Map.of("key", "value"));
// -> "key=value"
Security | 安全性:
- Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
- Null-safe: Configurable (skipNulls/useForNull) - 空值安全: 可配置
- Since:
- JDK 25, opencode-base-string V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescription<A extends Appendable>
A<A extends Appendable>
AappendTo(StringBuilder builder, Iterable<?> parts) static Joineron(char separator) static JoineruseForNull(String nullText) withKeyValueSeparator(char keyValueSeparator) withKeyValueSeparator(String keyValueSeparator)
-
Method Details
-
on
-
on
-
skipNulls
-
useForNull
-
join
-
join
-
join
-
join
-
appendTo
-
appendTo
-
appendTo
-
withKeyValueSeparator
-
withKeyValueSeparator
-