I annotate with Lombok. I need to override the setter method of one of the attributes. But this is not working.
I have annotated the property with @Setter(AccessLevel.NONE)
and then calling explicitly setProperty
.
The bean is mention below.
@Data
@AllArgsConstructor
@Slf4j
public class TestDto
{
private String code;
@Setter(AccessLevel.NONE)
private String nameCode;
public void setNameCode(String nameCode)
{
log.info(" nameCode {}", nameCode);
this.nameCode = <Call to some method>;
}
}
The DTO in which list of bean is getting set.
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TestViewDto {
private List<TestDto> testDtoList;
.............Few more dto's..............................
}
And this is been called from service below line..
travelAgentViewDto.setTestDto(repository.findTestNumber(number);
Repository interface is defined below:
public interface Repository extends JpaRepository<Address, AddressPk> {
public List<TestDto> findTestNumber(String number);
}
The code is working fine. Only issue is when overriding the setNameCode
the same is not going inside setter.
From setNameCode
method the below log should print: log.info(" nameCode {}", nameCode)
In actual the call is not going there.