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

import com.qsoft.rs.sincoar.dto.MdIndexDetailsDTO;
import com.qsoft.rs.sincoar.model.MdColumns;
import com.qsoft.rs.sincoar.model.MdIndexDetails;
import com.qsoft.rs.sincoar.model.MdIndexes;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.annotation.processing.Generated;

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

    @Override
    public MdIndexDetails getEntidad(MdIndexDetailsDTO mdIndexDetails) {
        if ( mdIndexDetails == null ) {
            return null;
        }

        MdIndexDetails mdIndexDetails1 = new MdIndexDetails();

        mdIndexDetails1.setColumnIdFk( mdIndexDetailsDTOToMdColumns( mdIndexDetails ) );
        mdIndexDetails1.setIndexIdFk( mdIndexDetailsDTOToMdIndexes( mdIndexDetails ) );
        if ( mdIndexDetails.getId() != null ) {
            mdIndexDetails1.setId( BigDecimal.valueOf( mdIndexDetails.getId() ) );
        }
        if ( mdIndexDetails.getIndexPortion() != null ) {
            mdIndexDetails1.setIndexPortion( BigInteger.valueOf( mdIndexDetails.getIndexPortion() ) );
        }
        if ( mdIndexDetails.getDetailOrder() != null ) {
            mdIndexDetails1.setDetailOrder( BigInteger.valueOf( mdIndexDetails.getDetailOrder() ) );
        }
        if ( mdIndexDetails.getSecurityGroupId() != null ) {
            mdIndexDetails1.setSecurityGroupId( BigInteger.valueOf( mdIndexDetails.getSecurityGroupId() ) );
        }
        mdIndexDetails1.setCreatedOn( mdIndexDetails.getCreatedOn() );
        mdIndexDetails1.setCreatedBy( mdIndexDetails.getCreatedBy() );
        mdIndexDetails1.setLastUpdatedOn( mdIndexDetails.getLastUpdatedOn() );
        mdIndexDetails1.setLastUpdatedBy( mdIndexDetails.getLastUpdatedBy() );

        validaNulos( mdIndexDetails, mdIndexDetails1 );

        return mdIndexDetails1;
    }

    @Override
    public MdIndexDetailsDTO getDto(MdIndexDetails mdIndexDetails) {
        if ( mdIndexDetails == null ) {
            return null;
        }

        MdIndexDetailsDTO mdIndexDetailsDTO = new MdIndexDetailsDTO();

        BigDecimal id = mdIndexDetailsColumnIdFkId( mdIndexDetails );
        if ( id != null ) {
            mdIndexDetailsDTO.setColumnIdFk( id.intValue() );
        }
        BigDecimal id1 = mdIndexDetailsIndexIdFkId( mdIndexDetails );
        if ( id1 != null ) {
            mdIndexDetailsDTO.setIndexIdFk( id1.intValue() );
        }
        if ( mdIndexDetails.getId() != null ) {
            mdIndexDetailsDTO.setId( mdIndexDetails.getId().intValue() );
        }
        if ( mdIndexDetails.getIndexPortion() != null ) {
            mdIndexDetailsDTO.setIndexPortion( mdIndexDetails.getIndexPortion().intValue() );
        }
        if ( mdIndexDetails.getDetailOrder() != null ) {
            mdIndexDetailsDTO.setDetailOrder( mdIndexDetails.getDetailOrder().intValue() );
        }
        if ( mdIndexDetails.getSecurityGroupId() != null ) {
            mdIndexDetailsDTO.setSecurityGroupId( mdIndexDetails.getSecurityGroupId().intValue() );
        }
        mdIndexDetailsDTO.setCreatedOn( mdIndexDetails.getCreatedOn() );
        mdIndexDetailsDTO.setCreatedBy( mdIndexDetails.getCreatedBy() );
        mdIndexDetailsDTO.setLastUpdatedOn( mdIndexDetails.getLastUpdatedOn() );
        mdIndexDetailsDTO.setLastUpdatedBy( mdIndexDetails.getLastUpdatedBy() );

        return mdIndexDetailsDTO;
    }

    protected MdColumns mdIndexDetailsDTOToMdColumns(MdIndexDetailsDTO mdIndexDetailsDTO) {
        if ( mdIndexDetailsDTO == null ) {
            return null;
        }

        MdColumns mdColumns = new MdColumns();

        if ( mdIndexDetailsDTO.getColumnIdFk() != null ) {
            mdColumns.setId( BigDecimal.valueOf( mdIndexDetailsDTO.getColumnIdFk() ) );
        }

        return mdColumns;
    }

    protected MdIndexes mdIndexDetailsDTOToMdIndexes(MdIndexDetailsDTO mdIndexDetailsDTO) {
        if ( mdIndexDetailsDTO == null ) {
            return null;
        }

        MdIndexes mdIndexes = new MdIndexes();

        if ( mdIndexDetailsDTO.getIndexIdFk() != null ) {
            mdIndexes.setId( BigDecimal.valueOf( mdIndexDetailsDTO.getIndexIdFk() ) );
        }

        return mdIndexes;
    }

    private BigDecimal mdIndexDetailsColumnIdFkId(MdIndexDetails mdIndexDetails) {
        if ( mdIndexDetails == null ) {
            return null;
        }
        MdColumns columnIdFk = mdIndexDetails.getColumnIdFk();
        if ( columnIdFk == null ) {
            return null;
        }
        BigDecimal id = columnIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }

    private BigDecimal mdIndexDetailsIndexIdFkId(MdIndexDetails mdIndexDetails) {
        if ( mdIndexDetails == null ) {
            return null;
        }
        MdIndexes indexIdFk = mdIndexDetails.getIndexIdFk();
        if ( indexIdFk == null ) {
            return null;
        }
        BigDecimal id = indexIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
