I am writing a Spring aspect and looking for a way to update a field on the returning object
My Dto's
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class BaseDto{
LocalDateTime testTime;
}
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class TestDto{
private BaseDto baseDtol
}
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class SampleDto{
private BaseDto baseDtol
}
My converters classes:
@TestAnnotation
public TestDto covert(){
return new TestDto()
}
@TestAnnotation
public SampleDto covert(){
return new SampleDto()
}
Aspect:
@Aspect
@Component
public class TestAspect {
@AfterReturning(value = "@annotation(TestAnnotation)", returning = "entity")
public void test(JoinPoint joinPoint, Object entity){
//Looking for a way to set BaseDto in the TestDto and SampleDto objects
}
}
My aspect would be called from the converters class and returning objects can be SampleDto and TestDto. I am looking for a way to set the BaseDto object in them.