Skip to content

Commit

Permalink
Use correct type for builder in generated introspections (#11511)
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher authored Jan 15, 2025
1 parent 3cf0bd3 commit 15b6194
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ private void processBuilderDefinition(ClassElement element, VisitorContext conte
creatorMethod,
writePrefixes,
methodElement,
element.getDefaultConstructor().orElse(null),
returnType.getDefaultConstructor().orElse(null),
returnType,
methodMetadata,
index,
Expand Down
23 changes: 23 additions & 0 deletions test-suite/src/test/java/io/micronaut/test/lombok/BarCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.micronaut.test.lombok;

import io.micronaut.core.annotation.Introspected;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Introspected
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class BarCommand {

private String foo;

private String bar;

private String baz;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@

public class LombokIntrospectedBuilderTest {

@Test
void testNoArgsAndAllArgsConstructor() {
BeanIntrospection<BarCommand> introspection = BeanIntrospection.getIntrospection(BarCommand.class);

BeanIntrospection.Builder<BarCommand> builder = introspection.builder();

builder.with("foo", "one");
builder.with("bar", "two");
builder.with("baz", "three");
BarCommand result = builder.build();
assertEquals("BarCommand(foo=one, bar=two, baz=three)", result.toString());
}

@Test
void testLombokNoArgsConstructor() {
BeanIntrospection<Book> introspection = BeanIntrospection.getIntrospection(Book.class);
Expand Down

0 comments on commit 15b6194

Please sign in to comment.