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

import com.qsoft.rs.sincoar.dto.MdConstraintsDTO;
import com.qsoft.rs.sincoar.model.MdConstraints;
import com.qsoft.rs.sincoar.model.MdTables;
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 MdConstraintsMapperImpl implements MdConstraintsMapper {

    @Override
    public MdConstraints getEntidad(MdConstraintsDTO mdConstraints) {
        if ( mdConstraints == null ) {
            return null;
        }

        MdConstraints mdConstraints1 = new MdConstraints();

        mdConstraints1.setTableIdFk( mdConstraintsDTOToMdTables( mdConstraints ) );
        if ( mdConstraints.getId() != null ) {
            mdConstraints1.setId( BigDecimal.valueOf( mdConstraints.getId() ) );
        }
        mdConstraints1.setDeleteClause( mdConstraints.getDeleteClause() );
        mdConstraints1.setName( mdConstraints.getName() );
        mdConstraints1.setConstraintType( mdConstraints.getConstraintType() );
        if ( mdConstraints.getReftableIdFk() != null ) {
            mdConstraints1.setReftableIdFk( BigInteger.valueOf( mdConstraints.getReftableIdFk() ) );
        }
        mdConstraints1.setConstraintText( mdConstraints.getConstraintText() );
        mdConstraints1.setLanguage( mdConstraints.getLanguage() );
        mdConstraints1.setComments( mdConstraints.getComments() );
        if ( mdConstraints.getSecurityGroupId() != null ) {
            mdConstraints1.setSecurityGroupId( BigInteger.valueOf( mdConstraints.getSecurityGroupId() ) );
        }
        mdConstraints1.setCreatedOn( mdConstraints.getCreatedOn() );
        mdConstraints1.setCreatedBy( mdConstraints.getCreatedBy() );
        mdConstraints1.setLastUpdatedOn( mdConstraints.getLastUpdatedOn() );
        mdConstraints1.setLastUpdatedBy( mdConstraints.getLastUpdatedBy() );

        validaNulos( mdConstraints, mdConstraints1 );

        return mdConstraints1;
    }

    @Override
    public MdConstraintsDTO getDto(MdConstraints mdConstraints) {
        if ( mdConstraints == null ) {
            return null;
        }

        MdConstraintsDTO mdConstraintsDTO = new MdConstraintsDTO();

        BigDecimal id = mdConstraintsTableIdFkId( mdConstraints );
        if ( id != null ) {
            mdConstraintsDTO.setTableIdFk( id.intValue() );
        }
        if ( mdConstraints.getId() != null ) {
            mdConstraintsDTO.setId( mdConstraints.getId().intValue() );
        }
        mdConstraintsDTO.setDeleteClause( mdConstraints.getDeleteClause() );
        mdConstraintsDTO.setName( mdConstraints.getName() );
        mdConstraintsDTO.setConstraintType( mdConstraints.getConstraintType() );
        if ( mdConstraints.getReftableIdFk() != null ) {
            mdConstraintsDTO.setReftableIdFk( mdConstraints.getReftableIdFk().intValue() );
        }
        mdConstraintsDTO.setConstraintText( mdConstraints.getConstraintText() );
        mdConstraintsDTO.setLanguage( mdConstraints.getLanguage() );
        mdConstraintsDTO.setComments( mdConstraints.getComments() );
        if ( mdConstraints.getSecurityGroupId() != null ) {
            mdConstraintsDTO.setSecurityGroupId( mdConstraints.getSecurityGroupId().intValue() );
        }
        mdConstraintsDTO.setCreatedOn( mdConstraints.getCreatedOn() );
        mdConstraintsDTO.setCreatedBy( mdConstraints.getCreatedBy() );
        mdConstraintsDTO.setLastUpdatedOn( mdConstraints.getLastUpdatedOn() );
        mdConstraintsDTO.setLastUpdatedBy( mdConstraints.getLastUpdatedBy() );

        return mdConstraintsDTO;
    }

    protected MdTables mdConstraintsDTOToMdTables(MdConstraintsDTO mdConstraintsDTO) {
        if ( mdConstraintsDTO == null ) {
            return null;
        }

        MdTables mdTables = new MdTables();

        if ( mdConstraintsDTO.getTableIdFk() != null ) {
            mdTables.setId( BigDecimal.valueOf( mdConstraintsDTO.getTableIdFk() ) );
        }

        return mdTables;
    }

    private BigDecimal mdConstraintsTableIdFkId(MdConstraints mdConstraints) {
        if ( mdConstraints == null ) {
            return null;
        }
        MdTables tableIdFk = mdConstraints.getTableIdFk();
        if ( tableIdFk == null ) {
            return null;
        }
        BigDecimal id = tableIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
