https://kotlinlang.org logo
Title
a

acoconut

01/25/2022, 6:21 PM
Question about mapstruct! I have this POJO:
data class WorkOrderCommentFilter constructor(
    val pagination: WorkOrderCommentPaginationFilter? = null,
    val id: Int? = null,
    val workOrderId: Int? = null,
    val comment: String? = null,
    val checkpointTypeName: String? = null,
    val createdAt: LocalDateTime? = null,
)
and this POJO:
@Introspected
data class WorkOrderCommentFilterDto constructor(
    @field:[QueryValue Parameter(description = "Pagination object")]
    val pagination: WorkOrderCommentPaginationFilter? = null,
    @field:[QueryValue Parameter(description = "Comment Id", example = "1")]
    val id: Int? = null,
    @field:[QueryValue Parameter(description = "WorkOrder Id", example = "1")]
    val workOrderId: Int? = null,
    @field:[QueryValue Parameter(description = "Comment message")]
    val comment: String? = null,
    @field:[QueryValue Parameter(description = "CheckpointType name")]
    val checkpointTypeName: String? = null,
    @field:[QueryValue Parameter(description = "Comment creation date")]
    val createdAt: Long? = null,
)
when I use a mapper like this:
@Mapper(componentModel = "jsr330", uses = [LocalDateTimeLongMapper::class])
interface WorkOrderCommentMapper {
     fun toDao(workOrderCommentFilterDto: WorkOrderCommentFilterDto): WorkOrderCommentFilter
}
The implementation is not right:
@Override
public WorkOrderCommentFilter toDao(WorkOrderCommentFilterDto workOrderCommentFilterDto) {
    if ( workOrderCommentFilterDto == null ) {
       return null;
   }

   WorkOrderCommentFilter workOrderCommentFilter = new WorkOrderCommentFilter();

   return workOrderCommentFilter;
}
I feel like I must be missing something, right? Thanks for any help in advance!
:thread-please: 1
m

Michael de Kaste

01/26/2022, 9:28 AM
what IDE are you working in that its not complaining about your implementation of
toDao
not having the correct type signature?
Since your implementation doesn't have a return type
a

acoconut

01/26/2022, 9:31 AM
what do you mean? I’m using intellij
m

Michael de Kaste

01/26/2022, 9:33 AM
your interface promises a return of WorkOrderCommentFilter. While your implementation override doesn't promise that return, it's a simple unit function
oh wait your implentation is java?
a

acoconut

01/26/2022, 9:37 AM
my implementation is the result from mapstruct. I actually got this response from them:
Issues concerning this have been reported, see mapstruct/mapstruct#2577 and mapstruct/mapstruct#2281 .