Skip to content

Commit 7b3e6d2

Browse files
committed
fix: isEmpty instead of length() == 0 in MapperAnnotationBuilder
1 parent 01cbc91 commit 7b3e6d2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -462,15 +462,15 @@ private void applyResults(Result[] results, Class<?> resultType, List<ResultMapp
462462

463463
private String findColumnPrefix(Result result) {
464464
String columnPrefix = result.one().columnPrefix();
465-
if (columnPrefix.length() < 1) {
465+
if (columnPrefix.isEmpty()) {
466466
columnPrefix = result.many().columnPrefix();
467467
}
468468
return columnPrefix;
469469
}
470470

471471
private String nestedResultMapId(Result result) {
472472
String resultMapId = result.one().resultMap();
473-
if (resultMapId.length() < 1) {
473+
if (resultMapId.isEmpty()) {
474474
resultMapId = result.many().resultMap();
475475
}
476476
if (!resultMapId.contains(".")) {
@@ -480,15 +480,15 @@ private String nestedResultMapId(Result result) {
480480
}
481481

482482
private boolean hasNestedResultMap(Result result) {
483-
if (result.one().resultMap().length() > 0 && result.many().resultMap().length() > 0) {
483+
if (!result.one().resultMap().isEmpty() && !result.many().resultMap().isEmpty()) {
484484
throw new BuilderException("Cannot use both @One and @Many annotations in the same @Result");
485485
}
486-
return result.one().resultMap().length() > 0 || result.many().resultMap().length() > 0;
486+
return !result.one().resultMap().isEmpty() || !result.many().resultMap().isEmpty();
487487
}
488488

489489
private String nestedSelectId(Result result) {
490490
String nestedSelect = result.one().select();
491-
if (nestedSelect.length() < 1) {
491+
if (nestedSelect.isEmpty()) {
492492
nestedSelect = result.many().select();
493493
}
494494
if (!nestedSelect.contains(".")) {
@@ -499,19 +499,19 @@ private String nestedSelectId(Result result) {
499499

500500
private boolean isLazy(Result result) {
501501
boolean isLazy = configuration.isLazyLoadingEnabled();
502-
if (result.one().select().length() > 0 && FetchType.DEFAULT != result.one().fetchType()) {
502+
if (!result.one().select().isEmpty() && FetchType.DEFAULT != result.one().fetchType()) {
503503
isLazy = result.one().fetchType() == FetchType.LAZY;
504-
} else if (result.many().select().length() > 0 && FetchType.DEFAULT != result.many().fetchType()) {
504+
} else if (!result.many().select().isEmpty() && FetchType.DEFAULT != result.many().fetchType()) {
505505
isLazy = result.many().fetchType() == FetchType.LAZY;
506506
}
507507
return isLazy;
508508
}
509509

510510
private boolean hasNestedSelect(Result result) {
511-
if (result.one().select().length() > 0 && result.many().select().length() > 0) {
511+
if (!result.one().select().isEmpty() && !result.many().select().isEmpty()) {
512512
throw new BuilderException("Cannot use both @One and @Many annotations in the same @Result");
513513
}
514-
return result.one().select().length() > 0 || result.many().select().length() > 0;
514+
return !result.one().select().isEmpty() || !result.many().select().isEmpty();
515515
}
516516

517517
private void applyConstructorArgs(Arg[] args, Class<?> resultType, List<ResultMapping> resultMappings,
@@ -539,7 +539,7 @@ private void applyConstructorArgs(Arg[] args, Class<?> resultType, List<ResultMa
539539
}
540540

541541
private String nullOrEmpty(String value) {
542-
return value == null || value.trim().length() == 0 ? null : value;
542+
return value == null || value.trim().isEmpty() ? null : value;
543543
}
544544

545545
private KeyGenerator handleSelectKeyAnnotation(SelectKey selectKeyAnnotation, String baseStatementId,

0 commit comments

Comments
 (0)