Skip to content

Commit

Permalink
fix: isEmpty instead of length() == 0 in MapperAnnotationBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
epochcoder committed Jan 6, 2025
1 parent 01cbc91 commit 7b3e6d2
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,15 +462,15 @@ private void applyResults(Result[] results, Class<?> resultType, List<ResultMapp

private String findColumnPrefix(Result result) {
String columnPrefix = result.one().columnPrefix();
if (columnPrefix.length() < 1) {
if (columnPrefix.isEmpty()) {
columnPrefix = result.many().columnPrefix();
}
return columnPrefix;
}

private String nestedResultMapId(Result result) {
String resultMapId = result.one().resultMap();
if (resultMapId.length() < 1) {
if (resultMapId.isEmpty()) {
resultMapId = result.many().resultMap();
}
if (!resultMapId.contains(".")) {
Expand All @@ -480,15 +480,15 @@ private String nestedResultMapId(Result result) {
}

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

private String nestedSelectId(Result result) {
String nestedSelect = result.one().select();
if (nestedSelect.length() < 1) {
if (nestedSelect.isEmpty()) {
nestedSelect = result.many().select();
}
if (!nestedSelect.contains(".")) {
Expand All @@ -499,19 +499,19 @@ private String nestedSelectId(Result result) {

private boolean isLazy(Result result) {
boolean isLazy = configuration.isLazyLoadingEnabled();
if (result.one().select().length() > 0 && FetchType.DEFAULT != result.one().fetchType()) {
if (!result.one().select().isEmpty() && FetchType.DEFAULT != result.one().fetchType()) {
isLazy = result.one().fetchType() == FetchType.LAZY;
} else if (result.many().select().length() > 0 && FetchType.DEFAULT != result.many().fetchType()) {
} else if (!result.many().select().isEmpty() && FetchType.DEFAULT != result.many().fetchType()) {
isLazy = result.many().fetchType() == FetchType.LAZY;
}
return isLazy;
}

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

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

private String nullOrEmpty(String value) {
return value == null || value.trim().length() == 0 ? null : value;
return value == null || value.trim().isEmpty() ? null : value;
}

private KeyGenerator handleSelectKeyAnnotation(SelectKey selectKeyAnnotation, String baseStatementId,
Expand Down

0 comments on commit 7b3e6d2

Please sign in to comment.