package com.qsoft.rs.sincoar.dominio.mapper;

import com.qsoft.rs.sincoar.dto.MigrGenerationOrderDTO;
import com.qsoft.rs.sincoar.model.MdConnections;
import com.qsoft.rs.sincoar.model.MigrGenerationOrder;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.annotation.processing.Generated;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2022-09-02T16:14:51-0500",
    comments = "version: 1.5.2.Final, compiler: javac, environment: Java 17.0.4 (Private Build)"
)
public class MigrGenerationOrderMapperImpl implements MigrGenerationOrderMapper {

    @Override
    public MigrGenerationOrder getEntidad(MigrGenerationOrderDTO migrGenerationOrder) {
        if ( migrGenerationOrder == null ) {
            return null;
        }

        MigrGenerationOrder migrGenerationOrder1 = new MigrGenerationOrder();

        migrGenerationOrder1.setConnectionIdFk( migrGenerationOrderDTOToMdConnections( migrGenerationOrder ) );
        if ( migrGenerationOrder.getId() != null ) {
            migrGenerationOrder1.setId( BigDecimal.valueOf( migrGenerationOrder.getId() ) );
        }
        if ( migrGenerationOrder.getObjectId() != null ) {
            migrGenerationOrder1.setObjectId( BigInteger.valueOf( migrGenerationOrder.getObjectId() ) );
        }
        migrGenerationOrder1.setObjectType( migrGenerationOrder.getObjectType() );
        if ( migrGenerationOrder.getGenerationOrder() != null ) {
            migrGenerationOrder1.setGenerationOrder( BigInteger.valueOf( migrGenerationOrder.getGenerationOrder() ) );
        }

        return migrGenerationOrder1;
    }

    @Override
    public MigrGenerationOrderDTO getDto(MigrGenerationOrder migrGenerationOrder) {
        if ( migrGenerationOrder == null ) {
            return null;
        }

        MigrGenerationOrderDTO migrGenerationOrderDTO = new MigrGenerationOrderDTO();

        BigDecimal id = migrGenerationOrderConnectionIdFkId( migrGenerationOrder );
        if ( id != null ) {
            migrGenerationOrderDTO.setConnectionIdFk( id.intValue() );
        }
        if ( migrGenerationOrder.getId() != null ) {
            migrGenerationOrderDTO.setId( migrGenerationOrder.getId().intValue() );
        }
        if ( migrGenerationOrder.getObjectId() != null ) {
            migrGenerationOrderDTO.setObjectId( migrGenerationOrder.getObjectId().intValue() );
        }
        migrGenerationOrderDTO.setObjectType( migrGenerationOrder.getObjectType() );
        if ( migrGenerationOrder.getGenerationOrder() != null ) {
            migrGenerationOrderDTO.setGenerationOrder( migrGenerationOrder.getGenerationOrder().intValue() );
        }

        return migrGenerationOrderDTO;
    }

    protected MdConnections migrGenerationOrderDTOToMdConnections(MigrGenerationOrderDTO migrGenerationOrderDTO) {
        if ( migrGenerationOrderDTO == null ) {
            return null;
        }

        MdConnections mdConnections = new MdConnections();

        if ( migrGenerationOrderDTO.getConnectionIdFk() != null ) {
            mdConnections.setId( BigDecimal.valueOf( migrGenerationOrderDTO.getConnectionIdFk() ) );
        }

        return mdConnections;
    }

    private BigDecimal migrGenerationOrderConnectionIdFkId(MigrGenerationOrder migrGenerationOrder) {
        if ( migrGenerationOrder == null ) {
            return null;
        }
        MdConnections connectionIdFk = migrGenerationOrder.getConnectionIdFk();
        if ( connectionIdFk == null ) {
            return null;
        }
        BigDecimal id = connectionIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
