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

import com.qsoft.rs.sincoar.dto.MdConstraintDetailsDTO;
import com.qsoft.rs.sincoar.model.MdColumns;
import com.qsoft.rs.sincoar.model.MdConstraintDetails;
import com.qsoft.rs.sincoar.model.MdConstraints;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.annotation.processing.Generated;

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

    @Override
    public MdConstraintDetails getEntidad(MdConstraintDetailsDTO mdConstraintDetails) {
        if ( mdConstraintDetails == null ) {
            return null;
        }

        MdConstraintDetails mdConstraintDetails1 = new MdConstraintDetails();

        mdConstraintDetails1.setColumnIdFk( mdConstraintDetailsDTOToMdColumns( mdConstraintDetails ) );
        mdConstraintDetails1.setConstraintIdFk( mdConstraintDetailsDTOToMdConstraints( mdConstraintDetails ) );
        if ( mdConstraintDetails.getId() != null ) {
            mdConstraintDetails1.setId( BigDecimal.valueOf( mdConstraintDetails.getId() ) );
        }
        mdConstraintDetails1.setRefFlag( mdConstraintDetails.getRefFlag() );
        if ( mdConstraintDetails.getColumnPortion() != null ) {
            mdConstraintDetails1.setColumnPortion( BigInteger.valueOf( mdConstraintDetails.getColumnPortion() ) );
        }
        mdConstraintDetails1.setConstraintText( mdConstraintDetails.getConstraintText() );
        if ( mdConstraintDetails.getDetailOrder() != null ) {
            mdConstraintDetails1.setDetailOrder( BigInteger.valueOf( mdConstraintDetails.getDetailOrder() ) );
        }
        if ( mdConstraintDetails.getSecurityGroupId() != null ) {
            mdConstraintDetails1.setSecurityGroupId( BigInteger.valueOf( mdConstraintDetails.getSecurityGroupId() ) );
        }
        mdConstraintDetails1.setCreatedOn( mdConstraintDetails.getCreatedOn() );
        mdConstraintDetails1.setCreatedBy( mdConstraintDetails.getCreatedBy() );
        mdConstraintDetails1.setLastUpdatedOn( mdConstraintDetails.getLastUpdatedOn() );
        mdConstraintDetails1.setLastUpdatedBy( mdConstraintDetails.getLastUpdatedBy() );

        validaNulos( mdConstraintDetails, mdConstraintDetails1 );

        return mdConstraintDetails1;
    }

    @Override
    public MdConstraintDetailsDTO getDto(MdConstraintDetails mdConstraintDetails) {
        if ( mdConstraintDetails == null ) {
            return null;
        }

        MdConstraintDetailsDTO mdConstraintDetailsDTO = new MdConstraintDetailsDTO();

        BigDecimal id = mdConstraintDetailsColumnIdFkId( mdConstraintDetails );
        if ( id != null ) {
            mdConstraintDetailsDTO.setColumnIdFk( id.intValue() );
        }
        BigDecimal id1 = mdConstraintDetailsConstraintIdFkId( mdConstraintDetails );
        if ( id1 != null ) {
            mdConstraintDetailsDTO.setConstraintIdFk( id1.intValue() );
        }
        if ( mdConstraintDetails.getId() != null ) {
            mdConstraintDetailsDTO.setId( mdConstraintDetails.getId().intValue() );
        }
        mdConstraintDetailsDTO.setRefFlag( mdConstraintDetails.getRefFlag() );
        if ( mdConstraintDetails.getColumnPortion() != null ) {
            mdConstraintDetailsDTO.setColumnPortion( mdConstraintDetails.getColumnPortion().intValue() );
        }
        mdConstraintDetailsDTO.setConstraintText( mdConstraintDetails.getConstraintText() );
        if ( mdConstraintDetails.getDetailOrder() != null ) {
            mdConstraintDetailsDTO.setDetailOrder( mdConstraintDetails.getDetailOrder().intValue() );
        }
        if ( mdConstraintDetails.getSecurityGroupId() != null ) {
            mdConstraintDetailsDTO.setSecurityGroupId( mdConstraintDetails.getSecurityGroupId().intValue() );
        }
        mdConstraintDetailsDTO.setCreatedOn( mdConstraintDetails.getCreatedOn() );
        mdConstraintDetailsDTO.setCreatedBy( mdConstraintDetails.getCreatedBy() );
        mdConstraintDetailsDTO.setLastUpdatedOn( mdConstraintDetails.getLastUpdatedOn() );
        mdConstraintDetailsDTO.setLastUpdatedBy( mdConstraintDetails.getLastUpdatedBy() );

        return mdConstraintDetailsDTO;
    }

    protected MdColumns mdConstraintDetailsDTOToMdColumns(MdConstraintDetailsDTO mdConstraintDetailsDTO) {
        if ( mdConstraintDetailsDTO == null ) {
            return null;
        }

        MdColumns mdColumns = new MdColumns();

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

        return mdColumns;
    }

    protected MdConstraints mdConstraintDetailsDTOToMdConstraints(MdConstraintDetailsDTO mdConstraintDetailsDTO) {
        if ( mdConstraintDetailsDTO == null ) {
            return null;
        }

        MdConstraints mdConstraints = new MdConstraints();

        if ( mdConstraintDetailsDTO.getConstraintIdFk() != null ) {
            mdConstraints.setId( BigDecimal.valueOf( mdConstraintDetailsDTO.getConstraintIdFk() ) );
        }

        return mdConstraints;
    }

    private BigDecimal mdConstraintDetailsColumnIdFkId(MdConstraintDetails mdConstraintDetails) {
        if ( mdConstraintDetails == null ) {
            return null;
        }
        MdColumns columnIdFk = mdConstraintDetails.getColumnIdFk();
        if ( columnIdFk == null ) {
            return null;
        }
        BigDecimal id = columnIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }

    private BigDecimal mdConstraintDetailsConstraintIdFkId(MdConstraintDetails mdConstraintDetails) {
        if ( mdConstraintDetails == null ) {
            return null;
        }
        MdConstraints constraintIdFk = mdConstraintDetails.getConstraintIdFk();
        if ( constraintIdFk == null ) {
            return null;
        }
        BigDecimal id = constraintIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
