Skip to content

Commit

Permalink
#2349 Make abstract methods of generated ModProp entity delegate to s…
Browse files Browse the repository at this point in the history
…etter and accessor of audit-entity property
  • Loading branch information
homedirectory committed Oct 29, 2024
1 parent a1cfdde commit 0a6fd44
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,19 @@ private void generateModPropEntity(
// Abstract methods in the base type

// AE getAuditedEntity();
final var auditEntityPropAccessor = auditEntityProp.getAccessorSpec(environment);
builder.addMethod(methodBuilder("getAuditedEntity")
.addModifiers(PUBLIC)
.returns(auditEntityProp.type())
.addStatement("return %s".formatted(auditEntityProp.name()))
.addStatement("return %s()".formatted(auditEntityPropAccessor.name))
.build());
// AbstractAuditModProp<AE> setAuditedEntity(AE entity);
final var auditEntityPropSetter = auditEntityProp.getSetterSpec(environment, modPropTypeClassName);
builder.addMethod(methodBuilder("setAuditedEntity")
.addModifiers(PUBLIC)
.returns(modPropTypeClassName)
.addParameter(auditEntityProp.type(), "entity", FINAL)
.addStatement("this.%s = %s".formatted(auditEntityProp.name(), "entity"))
.addStatement("return this")
.addParameter(auditEntityClassName, "entity", FINAL)
.addStatement("return %s(entity)".formatted(auditEntityPropSetter.name))
.build());

final var typeSpec = builder.build();
Expand Down

0 comments on commit 0a6fd44

Please sign in to comment.