Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
babyfish-ct committed Jan 19, 2025
1 parent a6c86e3 commit 26d360c
Showing 1 changed file with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private void addBuild() {
builder.endControlFlow();
builder.addStatement(
"_input.$L($L)",
StringUtil.identifier("set", prop.getName()),
setterName(prop),
prop.getName()
);
} else {
Expand All @@ -204,15 +204,15 @@ private void addBuild() {
case STATIC:
builder.addStatement(
"_input.$L($L)",
StringUtil.identifier("set", prop.getName()),
setterName(prop),
prop.getName()
);
break;
case DYNAMIC:
builder.beginControlFlow("if ($L)", stateFieldName);
builder.addStatement(
"_input.$L($L)",
StringUtil.identifier("set", prop.getName()),
setterName(prop),
prop.getName()
);
builder.endControlFlow();
Expand All @@ -221,7 +221,7 @@ private void addBuild() {
builder.beginControlFlow("if ($L != null)", prop.getName());
builder.addStatement(
"_input.$L($L)",
StringUtil.identifier("set", prop.getName()),
setterName(prop),
prop.getName()
);
builder.endControlFlow();
Expand All @@ -232,7 +232,7 @@ private void addBuild() {
for (UserProp prop : dtoType.getUserProps()) {
builder.addStatement(
"_input.$L($L)",
StringUtil.identifier("set", prop.getName()),
setterName(prop),
prop.getName()
);
}
Expand All @@ -256,4 +256,24 @@ private static boolean isJacksonQualifiedName(String qualifiedName) {
}
return false;
}

private static String setterName(DtoProp<?, ImmutableProp> prop) {
String name = prop.getName();
if (name.length() > 3 &&
name.startsWith("is") &&
prop.toTailProp().getBaseProp().getTypeName().equals(TypeName.BOOLEAN)) {
return StringUtil.identifier("set", prop.getName().substring(2));
}
return StringUtil.identifier("set", prop.getName());
}

private static String setterName(UserProp prop) {
String name = prop.getName();
if (name.length() > 3 &&
name.startsWith("is") &&
prop.getTypeRef().equals(TypeRef.TN_BOOLEAN)) {
return StringUtil.identifier("set", prop.getName().substring(2));
}
return StringUtil.identifier("set", prop.getName());
}
}

0 comments on commit 26d360c

Please sign in to comment.