CustomerMapperImpl.java

package com.github.jenkaby.bikerental.customer.application.mapper;

import com.github.jenkaby.bikerental.customer.CustomerInfo;
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 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 CustomerMapperImpl implements CustomerMapper {

    private final PhoneNumberMapper phoneNumberMapper;
    private final EmailAddressMapper emailAddressMapper;

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

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

    @Override
    public CustomerInfo toInfo(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;

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

        CustomerInfo customerInfo = new CustomerInfo( id, phone, firstName, lastName, email, birthDate );

        return customerInfo;
    }
}