Refine SourceFile record to class conversion
Update conversion logic to deal with annotations. See gh-29236
This commit is contained in:
@@ -146,6 +146,19 @@ class SourceFileTests {
|
||||
assertThat(sourceFile.getClassName()).isEqualTo("com.example.helloworld.HelloWorld");
|
||||
}
|
||||
|
||||
@Test
|
||||
void getClassNameFromAnnotatedRecord() {
|
||||
SourceFile sourceFile = SourceFile.of("""
|
||||
package com.example;
|
||||
|
||||
public record RecordProperties(
|
||||
@org.springframework.boot.context.properties.bind.DefaultValue("default-value-1") String property1,
|
||||
@org.springframework.boot.context.properties.bind.DefaultValue("default-value-2") String property2) {
|
||||
}
|
||||
""");
|
||||
assertThat(sourceFile.getClassName()).isEqualTo("com.example.RecordProperties");
|
||||
}
|
||||
|
||||
/**
|
||||
* JavaPoet style API with a {@code writeTo} method.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user