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

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

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

    @Override
    public MdMigrDependency getEntidad(MdMigrDependencyDTO mdMigrDependency) {
        if ( mdMigrDependency == null ) {
            return null;
        }

        MdMigrDependency mdMigrDependency1 = new MdMigrDependency();

        mdMigrDependency1.setConnectionIdFk( mdMigrDependencyDTOToMdConnections( mdMigrDependency ) );
        if ( mdMigrDependency.getId() != null ) {
            mdMigrDependency1.setId( BigDecimal.valueOf( mdMigrDependency.getId() ) );
        }
        if ( mdMigrDependency.getParentId() != null ) {
            mdMigrDependency1.setParentId( BigInteger.valueOf( mdMigrDependency.getParentId() ) );
        }
        if ( mdMigrDependency.getChildId() != null ) {
            mdMigrDependency1.setChildId( BigInteger.valueOf( mdMigrDependency.getChildId() ) );
        }
        mdMigrDependency1.setParentObjectType( mdMigrDependency.getParentObjectType() );
        mdMigrDependency1.setChildObjectType( mdMigrDependency.getChildObjectType() );
        if ( mdMigrDependency.getSecurityGroupId() != null ) {
            mdMigrDependency1.setSecurityGroupId( BigInteger.valueOf( mdMigrDependency.getSecurityGroupId() ) );
        }
        mdMigrDependency1.setCreatedOn( mdMigrDependency.getCreatedOn() );
        mdMigrDependency1.setCreatedBy( mdMigrDependency.getCreatedBy() );
        mdMigrDependency1.setLastUpdatedOn( mdMigrDependency.getLastUpdatedOn() );
        mdMigrDependency1.setLastUpdatedBy( mdMigrDependency.getLastUpdatedBy() );

        return mdMigrDependency1;
    }

    @Override
    public MdMigrDependencyDTO getDto(MdMigrDependency mdMigrDependency) {
        if ( mdMigrDependency == null ) {
            return null;
        }

        MdMigrDependencyDTO mdMigrDependencyDTO = new MdMigrDependencyDTO();

        BigDecimal id = mdMigrDependencyConnectionIdFkId( mdMigrDependency );
        if ( id != null ) {
            mdMigrDependencyDTO.setConnectionIdFk( id.intValue() );
        }
        if ( mdMigrDependency.getId() != null ) {
            mdMigrDependencyDTO.setId( mdMigrDependency.getId().intValue() );
        }
        if ( mdMigrDependency.getParentId() != null ) {
            mdMigrDependencyDTO.setParentId( mdMigrDependency.getParentId().intValue() );
        }
        if ( mdMigrDependency.getChildId() != null ) {
            mdMigrDependencyDTO.setChildId( mdMigrDependency.getChildId().intValue() );
        }
        mdMigrDependencyDTO.setParentObjectType( mdMigrDependency.getParentObjectType() );
        mdMigrDependencyDTO.setChildObjectType( mdMigrDependency.getChildObjectType() );
        if ( mdMigrDependency.getSecurityGroupId() != null ) {
            mdMigrDependencyDTO.setSecurityGroupId( mdMigrDependency.getSecurityGroupId().intValue() );
        }
        mdMigrDependencyDTO.setCreatedOn( mdMigrDependency.getCreatedOn() );
        mdMigrDependencyDTO.setCreatedBy( mdMigrDependency.getCreatedBy() );
        mdMigrDependencyDTO.setLastUpdatedOn( mdMigrDependency.getLastUpdatedOn() );
        mdMigrDependencyDTO.setLastUpdatedBy( mdMigrDependency.getLastUpdatedBy() );

        return mdMigrDependencyDTO;
    }

    protected MdConnections mdMigrDependencyDTOToMdConnections(MdMigrDependencyDTO mdMigrDependencyDTO) {
        if ( mdMigrDependencyDTO == null ) {
            return null;
        }

        MdConnections mdConnections = new MdConnections();

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

        return mdConnections;
    }

    private BigDecimal mdMigrDependencyConnectionIdFkId(MdMigrDependency mdMigrDependency) {
        if ( mdMigrDependency == null ) {
            return null;
        }
        MdConnections connectionIdFk = mdMigrDependency.getConnectionIdFk();
        if ( connectionIdFk == null ) {
            return null;
        }
        BigDecimal id = connectionIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
