[
https://issues.apache.org/jira/browse/GROOVY-11153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17754107#comment-17754107
]
Paul King edited comment on GROOVY-11153 at 8/14/23 1:55 PM:
-------------------------------------------------------------
It works if you use standard properties:
{code}
class BaseDto {
String phone
}
{code}
The options you have enabled should also work with pseudo properties.
was (Author: paulk):
It works if you use standard properties:
{code}
class BaseDto {
String phone
}
{code}
> groovy.transform.builder.Builder does not create methods for super-class
> setters
> --------------------------------------------------------------------------------
>
> Key: GROOVY-11153
> URL: https://issues.apache.org/jira/browse/GROOVY-11153
> Project: Groovy
> Issue Type: Bug
> Components: ast builder
> Affects Versions: 4.0.13
> Environment: Windows 10 x64, JDK 11
> Reporter: Yuri Kudryavtsev
> Priority: Major
> Attachments: 2023-08-14_11-49-17.png
>
>
> Groovy version: 4.0.13
> I have two classes.
> First base class:
> {code:java}
> class BaseDto {
> private String phone
> String getPhone() {
> return phone
> }
> void setPhone(String phone) {
> this.phone = phone
> }
> } {code}
> Second class, that extends first class:
> {code:java}
> @Builder(includeSuperProperties = true, useSetters = true, allProperties =
> true, allNames = true)
> class ExtendedDto extends BaseDto {
> String id
> String getId() {
> return id
> }
> void setId(String id) {
> this.id = id
> }
> } {code}
> I try to call builder like this:
> {code:java}
> ExtendedDto.builder().phone('123').build(){code}
> But exception has been thrown:
> {code:java}
> groovy.lang.MissingMethodException: No signature of method:
> ExtendedDto$ExtendedDtoBuilder.phone() is applicable for argument types:
> (String) values: [123]
> Possible solutions: print(java.io.PrintWriter), print(java.lang.Object),
> any(), find(), id(java.lang.String), any(groovy.lang.Closure)
> at
> org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
> at ExtendedDto$ExtendedDtoBuilder.methodMissing(ExtendedDto.groovy){code}
> It seems, that method
> {code:java}
> org.codehaus.groovy.transform.BuilderASTTransformation.AbstractBuilderStrategy#getPropertyInfoFromClassNode(org.codehaus.groovy.transform.BuilderASTTransformation,
> org.codehaus.groovy.ast.AnnotationNode, org.codehaus.groovy.ast.ClassNode,
> java.util.List<java.lang.String>, java.util.List<java.lang.String>, boolean,
> boolean){code}
> always calls method *BeanUtils.getAllProperties* with *includeSuperProperties
> = false.*
> Imho, *getPropertyInfoFromClassNode* should call *BeanUtils.getAllProperties*
> with *includeSuperProperties = true*, when DTO has annotation with
> *includeSuperProperties = true*.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)