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

import com.qsoft.rs.sincoar.dto.MdSynonymsDTO;
import com.qsoft.rs.sincoar.model.MdSchemas;
import com.qsoft.rs.sincoar.model.MdSynonyms;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.annotation.processing.Generated;

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

    @Override
    public MdSynonyms getEntidad(MdSynonymsDTO mdSynonyms) {
        if ( mdSynonyms == null ) {
            return null;
        }

        MdSynonyms mdSynonyms1 = new MdSynonyms();

        mdSynonyms1.setSchemaIdFk( mdSynonymsDTOToMdSchemas( mdSynonyms ) );
        if ( mdSynonyms.getId() != null ) {
            mdSynonyms1.setId( BigDecimal.valueOf( mdSynonyms.getId() ) );
        }
        mdSynonyms1.setName( mdSynonyms.getName() );
        if ( mdSynonyms.getSynonymForId() != null ) {
            mdSynonyms1.setSynonymForId( BigInteger.valueOf( mdSynonyms.getSynonymForId() ) );
        }
        mdSynonyms1.setForObjectType( mdSynonyms.getForObjectType() );
        mdSynonyms1.setPrivateVisibility( mdSynonyms.getPrivateVisibility() );
        mdSynonyms1.setNativeSql( mdSynonyms.getNativeSql() );
        mdSynonyms1.setNativeKey( mdSynonyms.getNativeKey() );
        mdSynonyms1.setComments( mdSynonyms.getComments() );
        if ( mdSynonyms.getSecurityGroupId() != null ) {
            mdSynonyms1.setSecurityGroupId( BigInteger.valueOf( mdSynonyms.getSecurityGroupId() ) );
        }
        mdSynonyms1.setCreatedOn( mdSynonyms.getCreatedOn() );
        mdSynonyms1.setCreatedBy( mdSynonyms.getCreatedBy() );
        mdSynonyms1.setLastUpdatedOn( mdSynonyms.getLastUpdatedOn() );
        mdSynonyms1.setLastUpdatedBy( mdSynonyms.getLastUpdatedBy() );

        return mdSynonyms1;
    }

    @Override
    public MdSynonymsDTO getDto(MdSynonyms mdSynonyms) {
        if ( mdSynonyms == null ) {
            return null;
        }

        MdSynonymsDTO mdSynonymsDTO = new MdSynonymsDTO();

        BigDecimal id = mdSynonymsSchemaIdFkId( mdSynonyms );
        if ( id != null ) {
            mdSynonymsDTO.setSchemaIdFk( id.intValue() );
        }
        if ( mdSynonyms.getId() != null ) {
            mdSynonymsDTO.setId( mdSynonyms.getId().intValue() );
        }
        mdSynonymsDTO.setName( mdSynonyms.getName() );
        if ( mdSynonyms.getSynonymForId() != null ) {
            mdSynonymsDTO.setSynonymForId( mdSynonyms.getSynonymForId().intValue() );
        }
        mdSynonymsDTO.setForObjectType( mdSynonyms.getForObjectType() );
        mdSynonymsDTO.setPrivateVisibility( mdSynonyms.getPrivateVisibility() );
        mdSynonymsDTO.setNativeSql( mdSynonyms.getNativeSql() );
        mdSynonymsDTO.setNativeKey( mdSynonyms.getNativeKey() );
        mdSynonymsDTO.setComments( mdSynonyms.getComments() );
        if ( mdSynonyms.getSecurityGroupId() != null ) {
            mdSynonymsDTO.setSecurityGroupId( mdSynonyms.getSecurityGroupId().intValue() );
        }
        mdSynonymsDTO.setCreatedOn( mdSynonyms.getCreatedOn() );
        mdSynonymsDTO.setCreatedBy( mdSynonyms.getCreatedBy() );
        mdSynonymsDTO.setLastUpdatedOn( mdSynonyms.getLastUpdatedOn() );
        mdSynonymsDTO.setLastUpdatedBy( mdSynonyms.getLastUpdatedBy() );

        return mdSynonymsDTO;
    }

    protected MdSchemas mdSynonymsDTOToMdSchemas(MdSynonymsDTO mdSynonymsDTO) {
        if ( mdSynonymsDTO == null ) {
            return null;
        }

        MdSchemas mdSchemas = new MdSchemas();

        if ( mdSynonymsDTO.getSchemaIdFk() != null ) {
            mdSchemas.setId( BigDecimal.valueOf( mdSynonymsDTO.getSchemaIdFk() ) );
        }

        return mdSchemas;
    }

    private BigDecimal mdSynonymsSchemaIdFkId(MdSynonyms mdSynonyms) {
        if ( mdSynonyms == null ) {
            return null;
        }
        MdSchemas schemaIdFk = mdSynonyms.getSchemaIdFk();
        if ( schemaIdFk == null ) {
            return null;
        }
        BigDecimal id = schemaIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
