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

import com.qsoft.rs.sincoar.dto.MdGroupsDTO;
import com.qsoft.rs.sincoar.model.MdGroups;
import com.qsoft.rs.sincoar.model.MdSchemas;
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 MdGroupsMapperImpl implements MdGroupsMapper {

    @Override
    public MdGroups getEntidad(MdGroupsDTO mdGroups) {
        if ( mdGroups == null ) {
            return null;
        }

        MdGroups mdGroups1 = new MdGroups();

        mdGroups1.setSchemaIdFk( mdGroupsDTOToMdSchemas( mdGroups ) );
        if ( mdGroups.getId() != null ) {
            mdGroups1.setId( BigDecimal.valueOf( mdGroups.getId() ) );
        }
        mdGroups1.setGroupName( mdGroups.getGroupName() );
        mdGroups1.setGroupFlag( mdGroups.getGroupFlag() );
        mdGroups1.setNativeSql( mdGroups.getNativeSql() );
        mdGroups1.setNativeKey( mdGroups.getNativeKey() );
        mdGroups1.setComments( mdGroups.getComments() );
        if ( mdGroups.getSecurityGroupId() != null ) {
            mdGroups1.setSecurityGroupId( BigInteger.valueOf( mdGroups.getSecurityGroupId() ) );
        }
        mdGroups1.setCreatedOn( mdGroups.getCreatedOn() );
        mdGroups1.setCreatedBy( mdGroups.getCreatedBy() );
        mdGroups1.setLastUpdatedOn( mdGroups.getLastUpdatedOn() );
        mdGroups1.setLastUpdatedBy( mdGroups.getLastUpdatedBy() );

        validaNulos( mdGroups, mdGroups1 );

        return mdGroups1;
    }

    @Override
    public MdGroupsDTO getDto(MdGroups mdGroups) {
        if ( mdGroups == null ) {
            return null;
        }

        MdGroupsDTO mdGroupsDTO = new MdGroupsDTO();

        BigDecimal id = mdGroupsSchemaIdFkId( mdGroups );
        if ( id != null ) {
            mdGroupsDTO.setSchemaIdFk( id.intValue() );
        }
        if ( mdGroups.getId() != null ) {
            mdGroupsDTO.setId( mdGroups.getId().intValue() );
        }
        mdGroupsDTO.setGroupName( mdGroups.getGroupName() );
        mdGroupsDTO.setGroupFlag( mdGroups.getGroupFlag() );
        mdGroupsDTO.setNativeSql( mdGroups.getNativeSql() );
        mdGroupsDTO.setNativeKey( mdGroups.getNativeKey() );
        mdGroupsDTO.setComments( mdGroups.getComments() );
        if ( mdGroups.getSecurityGroupId() != null ) {
            mdGroupsDTO.setSecurityGroupId( mdGroups.getSecurityGroupId().intValue() );
        }
        mdGroupsDTO.setCreatedOn( mdGroups.getCreatedOn() );
        mdGroupsDTO.setCreatedBy( mdGroups.getCreatedBy() );
        mdGroupsDTO.setLastUpdatedOn( mdGroups.getLastUpdatedOn() );
        mdGroupsDTO.setLastUpdatedBy( mdGroups.getLastUpdatedBy() );

        return mdGroupsDTO;
    }

    protected MdSchemas mdGroupsDTOToMdSchemas(MdGroupsDTO mdGroupsDTO) {
        if ( mdGroupsDTO == null ) {
            return null;
        }

        MdSchemas mdSchemas = new MdSchemas();

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

        return mdSchemas;
    }

    private BigDecimal mdGroupsSchemaIdFkId(MdGroups mdGroups) {
        if ( mdGroups == null ) {
            return null;
        }
        MdSchemas schemaIdFk = mdGroups.getSchemaIdFk();
        if ( schemaIdFk == null ) {
            return null;
        }
        BigDecimal id = schemaIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
