refactor: convert RandomStringUtils from Java to Kotlin with enhanced KDoc#86
Open
cto-new[bot] wants to merge 3 commits intomasterfrom
Open
refactor: convert RandomStringUtils from Java to Kotlin with enhanced KDoc#86cto-new[bot] wants to merge 3 commits intomasterfrom
cto-new[bot] wants to merge 3 commits intomasterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
将
RandomStringUtils从 Java 转换为 Kotlin,并完善了 KDoc 文档。Changes
1. 转换为 Kotlin
RandomStringUtils.javaRandomStringUtils.kt@file:JvmName("RandomStringUtils")保持 Java 兼容性@JvmStatic注解(顶层函数自动编译为静态方法)2. 完善 KDoc 文档
@sample标签)3. Kotlin 惯用法优化
buildString()替代StringBuilderrepeat()替代for循环List(size) { ... }构建列表emptyList()替代Collections.emptyList()filterNotNull()处理可空列表转换4. 命名改进
私有常量重命名为自解释形式:
SRC_NUMBER→NUMERIC_CHARSSRC_LOWER/SRC_UPPER→LOWERCASE_LETTERS/UPPERCASE_LETTERSSRC_HEX_LOWER/SRC_HEX_UPPER→HEX_LOWERCASE_CHARS/HEX_UPPERCASE_CHARSESC_CHAR→PLACEHOLDER_CHARlocker→LOCK5. Bug Fixes
subStringByLength返回类型不匹配的问题,添加了.filterNotNull()Backward Compatibility
Powered by CTO.new