TransactionMapperImpl.java

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

import com.github.jenkaby.bikerental.finance.PaymentMethod;
import com.github.jenkaby.bikerental.finance.application.usecase.GetTransactionHistoryUseCase;
import com.github.jenkaby.bikerental.finance.domain.model.Transaction;
import com.github.jenkaby.bikerental.finance.domain.model.TransactionSourceType;
import com.github.jenkaby.bikerental.finance.domain.model.TransactionType;
import com.github.jenkaby.bikerental.shared.mapper.MoneyMapper;
import java.math.BigDecimal;
import java.time.Instant;
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 TransactionMapperImpl implements TransactionMapper {

    private final MoneyMapper moneyMapper;

    @Autowired
    public TransactionMapperImpl(MoneyMapper moneyMapper) {

        this.moneyMapper = moneyMapper;
    }

    @Override
    public GetTransactionHistoryUseCase.TransactionDto toEntry(Transaction tx) {
        if ( tx == null ) {
            return null;
        }

        UUID customerId = null;
        BigDecimal amount = null;
        TransactionType type = null;
        Instant recordedAt = null;
        PaymentMethod paymentMethod = null;
        String reason = null;
        TransactionSourceType sourceType = null;
        String sourceId = null;

        customerId = tx.getCustomerId();
        amount = moneyMapper.toBigDecimal( tx.getAmount() );
        type = tx.getType();
        recordedAt = tx.getRecordedAt();
        paymentMethod = tx.getPaymentMethod();
        reason = tx.getReason();
        sourceType = tx.getSourceType();
        sourceId = tx.getSourceId();

        GetTransactionHistoryUseCase.TransactionDto transactionDto = new GetTransactionHistoryUseCase.TransactionDto( customerId, amount, type, recordedAt, paymentMethod, reason, sourceType, sourceId );

        return transactionDto;
    }
}