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

import com.qsoft.rs.sincoar.dto.MdDerivativesDTO;
import com.qsoft.rs.sincoar.model.MdConnections;
import com.qsoft.rs.sincoar.model.MdDerivatives;
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 MdDerivativesMapperImpl implements MdDerivativesMapper {

    @Override
    public MdDerivatives getEntidad(MdDerivativesDTO mdDerivatives) {
        if ( mdDerivatives == null ) {
            return null;
        }

        MdDerivatives mdDerivatives1 = new MdDerivatives();

        mdDerivatives1.setDerivedConnectionIdFk( mdDerivativesDTOToMdConnections( mdDerivatives ) );
        if ( mdDerivatives.getId() != null ) {
            mdDerivatives1.setId( BigDecimal.valueOf( mdDerivatives.getId() ) );
        }
        if ( mdDerivatives.getSrcId() != null ) {
            mdDerivatives1.setSrcId( BigInteger.valueOf( mdDerivatives.getSrcId() ) );
        }
        mdDerivatives1.setSrcType( mdDerivatives.getSrcType() );
        if ( mdDerivatives.getDerivedId() != null ) {
            mdDerivatives1.setDerivedId( BigInteger.valueOf( mdDerivatives.getDerivedId() ) );
        }
        mdDerivatives1.setDerivedType( mdDerivatives.getDerivedType() );
        mdDerivatives1.setTransformed( mdDerivatives.getTransformed() );
        mdDerivatives1.setOriginalIdentifier( mdDerivatives.getOriginalIdentifier() );
        mdDerivatives1.setNewIdentifier( mdDerivatives.getNewIdentifier() );
        mdDerivatives1.setDerivedObjectNamespace( mdDerivatives.getDerivedObjectNamespace() );
        mdDerivatives1.setDerivativeReason( mdDerivatives.getDerivativeReason() );
        if ( mdDerivatives.getSecurityGroupId() != null ) {
            mdDerivatives1.setSecurityGroupId( BigInteger.valueOf( mdDerivatives.getSecurityGroupId() ) );
        }
        mdDerivatives1.setCreatedOn( mdDerivatives.getCreatedOn() );
        mdDerivatives1.setCreatedBy( mdDerivatives.getCreatedBy() );
        mdDerivatives1.setLastUpdatedOn( mdDerivatives.getLastUpdatedOn() );
        mdDerivatives1.setLastUpdatedBy( mdDerivatives.getLastUpdatedBy() );

        validaNulos( mdDerivatives, mdDerivatives1 );

        return mdDerivatives1;
    }

    @Override
    public MdDerivativesDTO getDto(MdDerivatives mdDerivatives) {
        if ( mdDerivatives == null ) {
            return null;
        }

        MdDerivativesDTO mdDerivativesDTO = new MdDerivativesDTO();

        BigDecimal id = mdDerivativesDerivedConnectionIdFkId( mdDerivatives );
        if ( id != null ) {
            mdDerivativesDTO.setDerivedConnectionIdFk( id.intValue() );
        }
        if ( mdDerivatives.getId() != null ) {
            mdDerivativesDTO.setId( mdDerivatives.getId().intValue() );
        }
        if ( mdDerivatives.getSrcId() != null ) {
            mdDerivativesDTO.setSrcId( mdDerivatives.getSrcId().intValue() );
        }
        mdDerivativesDTO.setSrcType( mdDerivatives.getSrcType() );
        if ( mdDerivatives.getDerivedId() != null ) {
            mdDerivativesDTO.setDerivedId( mdDerivatives.getDerivedId().intValue() );
        }
        mdDerivativesDTO.setDerivedType( mdDerivatives.getDerivedType() );
        mdDerivativesDTO.setTransformed( mdDerivatives.getTransformed() );
        mdDerivativesDTO.setOriginalIdentifier( mdDerivatives.getOriginalIdentifier() );
        mdDerivativesDTO.setNewIdentifier( mdDerivatives.getNewIdentifier() );
        mdDerivativesDTO.setDerivedObjectNamespace( mdDerivatives.getDerivedObjectNamespace() );
        mdDerivativesDTO.setDerivativeReason( mdDerivatives.getDerivativeReason() );
        if ( mdDerivatives.getSecurityGroupId() != null ) {
            mdDerivativesDTO.setSecurityGroupId( mdDerivatives.getSecurityGroupId().intValue() );
        }
        mdDerivativesDTO.setCreatedOn( mdDerivatives.getCreatedOn() );
        mdDerivativesDTO.setCreatedBy( mdDerivatives.getCreatedBy() );
        mdDerivativesDTO.setLastUpdatedOn( mdDerivatives.getLastUpdatedOn() );
        mdDerivativesDTO.setLastUpdatedBy( mdDerivatives.getLastUpdatedBy() );

        return mdDerivativesDTO;
    }

    protected MdConnections mdDerivativesDTOToMdConnections(MdDerivativesDTO mdDerivativesDTO) {
        if ( mdDerivativesDTO == null ) {
            return null;
        }

        MdConnections mdConnections = new MdConnections();

        if ( mdDerivativesDTO.getDerivedConnectionIdFk() != null ) {
            mdConnections.setId( BigDecimal.valueOf( mdDerivativesDTO.getDerivedConnectionIdFk() ) );
        }

        return mdConnections;
    }

    private BigDecimal mdDerivativesDerivedConnectionIdFkId(MdDerivatives mdDerivatives) {
        if ( mdDerivatives == null ) {
            return null;
        }
        MdConnections derivedConnectionIdFk = mdDerivatives.getDerivedConnectionIdFk();
        if ( derivedConnectionIdFk == null ) {
            return null;
        }
        BigDecimal id = derivedConnectionIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
