Skip to content

Commit 964bd58

Browse files
committed
Simplify reflection
1 parent de24abe commit 964bd58

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

core/src/main/java/com/orange/ouds/core/component/common/text/OudsAnnotatedString.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,12 @@ internal fun <T, U> buildOudsAnnotatedString(
463463
builderClass: Class<T>,
464464
builder: (T).() -> Unit
465465
): U where T : OudsAnnotatedString.Builder<U>, U : OudsAnnotatedString<U> {
466-
val constructor: () -> T = { builderClass.getConstructor().newInstance() }
467-
return constructor().apply { builder() }.toAnnotatedString()
466+
return builderClass.getConstructor()
467+
.newInstance()
468+
.apply(builder)
469+
.toAnnotatedString()
468470
}
469471

470472
private fun <T> createOudsAnnotatedString(annotatedString: AnnotatedString, clazz: Class<T>): T where T : OudsAnnotatedString<T> {
471-
val constructor: (AnnotatedString) -> T = { clazz.getConstructor(AnnotatedString::class.java).newInstance(it) }
472-
return constructor(annotatedString)
473+
return clazz.getConstructor(AnnotatedString::class.java).newInstance(annotatedString)
473474
}

0 commit comments

Comments
 (0)