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

import com.qsoft.rs.sincoar.dto.MdSequencesDTO;
import com.qsoft.rs.sincoar.model.MdSchemas;
import com.qsoft.rs.sincoar.model.MdSequences;
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 MdSequencesMapperImpl implements MdSequencesMapper {

    @Override
    public MdSequences getEntidad(MdSequencesDTO mdSequences) {
        if ( mdSequences == null ) {
            return null;
        }

        MdSequences mdSequences1 = new MdSequences();

        mdSequences1.setSchemaIdFk( mdSequencesDTOToMdSchemas( mdSequences ) );
        if ( mdSequences.getId() != null ) {
            mdSequences1.setId( BigDecimal.valueOf( mdSequences.getId() ) );
        }
        mdSequences1.setName( mdSequences.getName() );
        if ( mdSequences.getSeqStart() != null ) {
            mdSequences1.setSeqStart( BigInteger.valueOf( mdSequences.getSeqStart() ) );
        }
        if ( mdSequences.getIncr() != null ) {
            mdSequences1.setIncr( BigInteger.valueOf( mdSequences.getIncr() ) );
        }
        mdSequences1.setNativeSql( mdSequences.getNativeSql() );
        mdSequences1.setNativeKey( mdSequences.getNativeKey() );
        mdSequences1.setComments( mdSequences.getComments() );
        if ( mdSequences.getSecurityGroupId() != null ) {
            mdSequences1.setSecurityGroupId( BigInteger.valueOf( mdSequences.getSecurityGroupId() ) );
        }
        mdSequences1.setCreatedOn( mdSequences.getCreatedOn() );
        mdSequences1.setCreatedBy( mdSequences.getCreatedBy() );
        mdSequences1.setLastUpdatedOn( mdSequences.getLastUpdatedOn() );
        mdSequences1.setLastUpdatedBy( mdSequences.getLastUpdatedBy() );

        return mdSequences1;
    }

    @Override
    public MdSequencesDTO getDto(MdSequences mdSequences) {
        if ( mdSequences == null ) {
            return null;
        }

        MdSequencesDTO mdSequencesDTO = new MdSequencesDTO();

        BigDecimal id = mdSequencesSchemaIdFkId( mdSequences );
        if ( id != null ) {
            mdSequencesDTO.setSchemaIdFk( id.intValue() );
        }
        if ( mdSequences.getId() != null ) {
            mdSequencesDTO.setId( mdSequences.getId().intValue() );
        }
        mdSequencesDTO.setName( mdSequences.getName() );
        if ( mdSequences.getSeqStart() != null ) {
            mdSequencesDTO.setSeqStart( mdSequences.getSeqStart().intValue() );
        }
        if ( mdSequences.getIncr() != null ) {
            mdSequencesDTO.setIncr( mdSequences.getIncr().intValue() );
        }
        mdSequencesDTO.setNativeSql( mdSequences.getNativeSql() );
        mdSequencesDTO.setNativeKey( mdSequences.getNativeKey() );
        mdSequencesDTO.setComments( mdSequences.getComments() );
        if ( mdSequences.getSecurityGroupId() != null ) {
            mdSequencesDTO.setSecurityGroupId( mdSequences.getSecurityGroupId().intValue() );
        }
        mdSequencesDTO.setCreatedOn( mdSequences.getCreatedOn() );
        mdSequencesDTO.setCreatedBy( mdSequences.getCreatedBy() );
        mdSequencesDTO.setLastUpdatedOn( mdSequences.getLastUpdatedOn() );
        mdSequencesDTO.setLastUpdatedBy( mdSequences.getLastUpdatedBy() );

        return mdSequencesDTO;
    }

    protected MdSchemas mdSequencesDTOToMdSchemas(MdSequencesDTO mdSequencesDTO) {
        if ( mdSequencesDTO == null ) {
            return null;
        }

        MdSchemas mdSchemas = new MdSchemas();

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

        return mdSchemas;
    }

    private BigDecimal mdSequencesSchemaIdFkId(MdSequences mdSequences) {
        if ( mdSequences == null ) {
            return null;
        }
        MdSchemas schemaIdFk = mdSequences.getSchemaIdFk();
        if ( schemaIdFk == null ) {
            return null;
        }
        BigDecimal id = schemaIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
