Skip to content

Commit fdae805

Browse files
committed
refactor: optimize entityClass acquisition mechanism
1 parent 56bb0ae commit fdae805

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/kotlin/team/yi/rsql/querydsl/QuerydslRsql.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,14 @@ class QuerydslRsql<E> private constructor(builder: Builder<E>) {
285285

286286
requireNotNull(rsqlConfig.entityManager) { "Entity manager cannot be null." }
287287

288-
this.entityClass = when (builder.entityClass) {
289-
null -> RsqlUtil.getClassForEntityString(builder.entityName!!, rsqlConfig.entityManager) as Class<E>?
290-
else -> builder.entityClass
291-
} ?: throw EntityNotFoundException("Can't find entity with name: " + builder.entityName, builder.entityName)
288+
val entityClass = builder.entityClass
289+
val entityName = builder.entityName
290+
291+
this.entityClass = when {
292+
entityClass != null -> entityClass
293+
entityName != null -> RsqlUtil.getClassForEntityString(entityName, rsqlConfig.entityManager) as Class<E>?
294+
else -> null
295+
} ?: throw EntityNotFoundException("Can't find entity with name: $entityName", entityName)
292296

293297
this.select = builder.select
294298
this.expressionSelect = builder.expressionSelect

0 commit comments

Comments
 (0)