CustomerCommandMapperImpl.java

package com.github.jenkaby.bikerental.customer.web.command.mapper;

import com.github.jenkaby.bikerental.customer.application.usecase.CreateCustomerUseCase;
import com.github.jenkaby.bikerental.customer.application.usecase.UpdateCustomerUseCase;
import com.github.jenkaby.bikerental.customer.domain.model.Customer;
import com.github.jenkaby.bikerental.customer.shared.mapper.EmailAddressMapper;
import com.github.jenkaby.bikerental.customer.shared.mapper.PhoneNumberMapper;
import com.github.jenkaby.bikerental.customer.web.command.dto.CustomerRequest;
import com.github.jenkaby.bikerental.customer.web.query.dto.CustomerResponse;
import java.time.LocalDate;
import java.util.UUID;
import javax.annotation.processing.Generated;
import org.springframework.beans.factory.annotation.Autowired;
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 CustomerCommandMapperImpl implements CustomerCommandMapper {

    private final PhoneNumberMapper phoneNumberMapper;
    private final EmailAddressMapper emailAddressMapper;

    @Autowired
    public CustomerCommandMapperImpl(PhoneNumberMapper phoneNumberMapper, EmailAddressMapper emailAddressMapper) {

        this.phoneNumberMapper = phoneNumberMapper;
        this.emailAddressMapper = emailAddressMapper;
    }

    @Override
    public CreateCustomerUseCase.CreateCustomerCommand toCreateCommand(CustomerRequest request) {
        if ( request == null ) {
            return null;
        }

        String phone = null;
        String firstName = null;
        String lastName = null;
        String email = null;
        LocalDate birthDate = null;
        String comments = null;

        phone = request.phone();
        firstName = request.firstName();
        lastName = request.lastName();
        email = request.email();
        birthDate = request.birthDate();
        comments = request.comments();

        CreateCustomerUseCase.CreateCustomerCommand createCustomerCommand = new CreateCustomerUseCase.CreateCustomerCommand( phone, firstName, lastName, email, birthDate, comments );

        return createCustomerCommand;
    }

    @Override
    public UpdateCustomerUseCase.UpdateCustomerCommand toUpdateCommand(UUID customerId, CustomerRequest request) {
        if ( customerId == null && request == null ) {
            return null;
        }

        String phone = null;
        String firstName = null;
        String lastName = null;
        String email = null;
        LocalDate birthDate = null;
        String comments = null;
        if ( request != null ) {
            phone = request.phone();
            firstName = request.firstName();
            lastName = request.lastName();
            email = request.email();
            birthDate = request.birthDate();
            comments = request.comments();
        }
        UUID customerId1 = null;
        customerId1 = customerId;

        UpdateCustomerUseCase.UpdateCustomerCommand updateCustomerCommand = new UpdateCustomerUseCase.UpdateCustomerCommand( customerId1, phone, firstName, lastName, email, birthDate, comments );

        return updateCustomerCommand;
    }

    @Override
    public CustomerResponse toResponse(Customer customer) {
        if ( customer == null ) {
            return null;
        }

        UUID id = null;
        String phone = null;
        String firstName = null;
        String lastName = null;
        String email = null;
        LocalDate birthDate = null;
        String comments = null;

        id = customer.getId();
        phone = phoneNumberMapper.toString( customer.getPhone() );
        firstName = customer.getFirstName();
        lastName = customer.getLastName();
        email = emailAddressMapper.toString( customer.getEmail() );
        birthDate = customer.getBirthDate();
        comments = customer.getComments();

        CustomerResponse customerResponse = new CustomerResponse( id, phone, firstName, lastName, email, birthDate, comments );

        return customerResponse;
    }
}