[BUG] @JsonProperty annotation is not propagated to record field and builder method
Closed this issue · 2 comments
zielu commented
Describe the bug
Create an interface with method annotated with @JsonProperty, after generation annotation is not propagated
Details
Details needed to reproduce bug:
- Library version: '3.0.0'
- Interface being processed:
@DefaultAutoRecordApi
public interface TestRecord {
@JsonProperty
String name();
}
Annotation
@Retention(SOURCE)
@Target(TYPE)
@AutoRecord.Template(
recordOptions = @AutoRecord.Options(withBuilder = true),
builderOptions = @RecordBuilder.Options(enableWither = false, useImmutableCollections = false, useUnmodifiableCollections = false),
extensions = @AutoRecord.Extension(extensionClass = "pl.com.labaj.autorecord.extension.arice.ImmutableCollectionsExtension")
)
public @interface DefaultAutoRecordApi {}
- Generated record:
@Generated("pl.com.labaj.autorecord.AutoRecord")
@GeneratedWithAutoRecord
@RecordBuilder
@RecordBuilder.Options(
addClassRetainedGenerated = true,
enableWither = false
)
public record TestRecordRecord(String name) implements TestRecord {
public TestRecordRecord {
// pl.com.labaj.autorecord.processor.AutoRecordProcessor
requireNonNull(name, "name must not be null");
}
public static TestRecordRecordBuilder builder() {
return TestRecordRecordBuilder.builder();
}
public TestRecordRecordBuilder toBuilder() {
return TestRecordRecordBuilder.builder(this);
}
}
Builder
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
@RecordBuilderGenerated
public class TestRecordRecordBuilder {
private String name;
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
private TestRecordRecordBuilder() {
}
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
private TestRecordRecordBuilder(String name) {
this.name = name;
}
/**
* Static constructor/builder. Can be used instead of new TestRecordRecord(...)
*/
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
public static TestRecordRecord TestRecordRecord(String name) {
return new TestRecordRecord(name);
}
/**
* Return a new builder with all fields set to default Java values
*/
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
public static TestRecordRecordBuilder builder() {
return new TestRecordRecordBuilder();
}
/**
* Return a new builder with all fields set to the values taken from the given record instance
*/
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
public static TestRecordRecordBuilder builder(TestRecordRecord from) {
return new TestRecordRecordBuilder(from.name());
}
/**
* Return a stream of the record components as map entries keyed with the component name and the value as the component value
*/
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
public static Stream<Map.Entry<String, Object>> stream(TestRecordRecord record) {
return Stream.of(new AbstractMap.SimpleImmutableEntry<>("name", record.name()));
}
/**
* Return a new record instance with all fields set to the current values in this builder
*/
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
public TestRecordRecord build() {
return new TestRecordRecord(name);
}
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
@Override
public String toString() {
return "TestRecordRecordBuilder[name=" + name + "]";
}
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
@Override
public int hashCode() {
return Objects.hash(name);
}
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
@Override
public boolean equals(Object o) {
return (this == o) || ((o instanceof TestRecordRecordBuilder r)
&& Objects.equals(name, r.name));
}
/**
* Set a new value for the {@code name} record component in the builder
*/
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
public TestRecordRecordBuilder name(String name) {
this.name = name;
return this;
}
/**
* Return the current value for the {@code name} record component in the builder
*/
@Generated("io.soabase.recordbuilder.core.RecordBuilder")
public String name() {
return name;
}
Expected behavior
@JsonProperty annotation being present on record field declaration and builder's name(...) method.
Additional context
Add any other context about the problem here.
create-issue-branch commented
pawellabaj commented