EquipmentQueryMapperImpl.java

package com.github.jenkaby.bikerental.equipment.web.query.mapper;

import com.github.jenkaby.bikerental.equipment.application.usecase.SearchEquipmentsUseCase;
import com.github.jenkaby.bikerental.equipment.domain.model.Equipment;
import com.github.jenkaby.bikerental.equipment.shared.mapper.SerialNumberMapper;
import com.github.jenkaby.bikerental.equipment.shared.mapper.UidMapper;
import com.github.jenkaby.bikerental.equipment.web.query.dto.EquipmentResponse;
import com.github.jenkaby.bikerental.shared.domain.model.vo.PageRequest;
import com.github.jenkaby.bikerental.shared.mapper.PageMapper;
import java.time.LocalDate;
import javax.annotation.processing.Generated;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    comments = "version: 1.6.3, compiler: IncrementalProcessingEnvironment from gradle-language-java-9.4.1.jar, environment: Java 21.0.10 (Amazon.com Inc.)"
)
@Component
public class EquipmentQueryMapperImpl implements EquipmentQueryMapper {

    private final UidMapper uidMapper;
    private final SerialNumberMapper serialNumberMapper;
    private final PageMapper pageMapper;

    @Autowired
    public EquipmentQueryMapperImpl(UidMapper uidMapper, SerialNumberMapper serialNumberMapper, PageMapper pageMapper) {

        this.uidMapper = uidMapper;
        this.serialNumberMapper = serialNumberMapper;
        this.pageMapper = pageMapper;
    }

    @Override
    public EquipmentResponse toResponse(Equipment equipment) {
        if ( equipment == null ) {
            return null;
        }

        String status = null;
        String type = null;
        Long id = null;
        String serialNumber = null;
        String uid = null;
        String model = null;
        LocalDate commissionedAt = null;
        String condition = null;

        status = equipment.getStatusSlug();
        type = equipment.getTypeSlug();
        id = equipment.getId();
        serialNumber = serialNumberMapper.toString( equipment.getSerialNumber() );
        uid = uidMapper.toString( equipment.getUid() );
        model = equipment.getModel();
        commissionedAt = equipment.getCommissionedAt();
        condition = equipment.getCondition();

        EquipmentResponse equipmentResponse = new EquipmentResponse( id, serialNumber, uid, type, status, model, commissionedAt, condition );

        return equipmentResponse;
    }

    @Override
    public SearchEquipmentsUseCase.SearchEquipmentsQuery toSearchQuery(String status, String type, Pageable pageable) {
        if ( status == null && type == null && pageable == null ) {
            return null;
        }

        String statusSlug = null;
        statusSlug = status;
        String typeSlug = null;
        typeSlug = type;
        PageRequest pageRequest = null;
        pageRequest = pageMapper.toPageRequest( pageable );

        SearchEquipmentsUseCase.SearchEquipmentsQuery searchEquipmentsQuery = new SearchEquipmentsUseCase.SearchEquipmentsQuery( statusSlug, typeSlug, pageRequest );

        return searchEquipmentsQuery;
    }
}