CustomerCommandToDomainMapperImpl.java
package com.github.jenkaby.bikerental.customer.application.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 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 CustomerCommandToDomainMapperImpl implements CustomerCommandToDomainMapper {
private final PhoneNumberMapper phoneNumberMapper;
private final EmailAddressMapper emailAddressMapper;
@Autowired
public CustomerCommandToDomainMapperImpl(PhoneNumberMapper phoneNumberMapper, EmailAddressMapper emailAddressMapper) {
this.phoneNumberMapper = phoneNumberMapper;
this.emailAddressMapper = emailAddressMapper;
}
@Override
public Customer toCustomer(CreateCustomerUseCase.CreateCustomerCommand command) {
if ( command == null ) {
return null;
}
Customer.CustomerBuilder customer = Customer.builder();
customer.phone( phoneNumberMapper.toPhoneNumber( command.phone() ) );
customer.firstName( command.firstName() );
customer.lastName( command.lastName() );
customer.email( emailAddressMapper.toEmailAddress( command.email() ) );
customer.birthDate( command.birthDate() );
customer.comments( command.comments() );
return customer.build();
}
@Override
public Customer toCustomer(UpdateCustomerUseCase.UpdateCustomerCommand command) {
if ( command == null ) {
return null;
}
Customer.CustomerBuilder customer = Customer.builder();
customer.id( command.customerId() );
customer.phone( phoneNumberMapper.toPhoneNumber( command.phone() ) );
customer.firstName( command.firstName() );
customer.lastName( command.lastName() );
customer.email( emailAddressMapper.toEmailAddress( command.email() ) );
customer.birthDate( command.birthDate() );
customer.comments( command.comments() );
return customer.build();
}
}