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

import com.qsoft.rs.sincoar.dto.MdOtherObjectsDTO;
import com.qsoft.rs.sincoar.model.MdOtherObjects;
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:49-0500",
    comments = "version: 1.5.2.Final, compiler: javac, environment: Java 17.0.4 (Private Build)"
)
public class MdOtherObjectsMapperImpl implements MdOtherObjectsMapper {

    @Override
    public MdOtherObjects getEntidad(MdOtherObjectsDTO mdOtherObjects) {
        if ( mdOtherObjects == null ) {
            return null;
        }

        MdOtherObjects mdOtherObjects1 = new MdOtherObjects();

        mdOtherObjects1.setSchemaIdFk( mdOtherObjectsDTOToMdSchemas( mdOtherObjects ) );
        if ( mdOtherObjects.getId() != null ) {
            mdOtherObjects1.setId( BigDecimal.valueOf( mdOtherObjects.getId() ) );
        }
        mdOtherObjects1.setName( mdOtherObjects.getName() );
        mdOtherObjects1.setNativeSql( mdOtherObjects.getNativeSql() );
        mdOtherObjects1.setNativeKey( mdOtherObjects.getNativeKey() );
        mdOtherObjects1.setComments( mdOtherObjects.getComments() );
        if ( mdOtherObjects.getSecurityGroupId() != null ) {
            mdOtherObjects1.setSecurityGroupId( BigInteger.valueOf( mdOtherObjects.getSecurityGroupId() ) );
        }
        mdOtherObjects1.setCreatedOn( mdOtherObjects.getCreatedOn() );
        mdOtherObjects1.setCreatedBy( mdOtherObjects.getCreatedBy() );
        mdOtherObjects1.setLastUpdatedOn( mdOtherObjects.getLastUpdatedOn() );
        mdOtherObjects1.setLastUpdatedBy( mdOtherObjects.getLastUpdatedBy() );

        return mdOtherObjects1;
    }

    @Override
    public MdOtherObjectsDTO getDto(MdOtherObjects mdOtherObjects) {
        if ( mdOtherObjects == null ) {
            return null;
        }

        MdOtherObjectsDTO mdOtherObjectsDTO = new MdOtherObjectsDTO();

        BigDecimal id = mdOtherObjectsSchemaIdFkId( mdOtherObjects );
        if ( id != null ) {
            mdOtherObjectsDTO.setSchemaIdFk( id.intValue() );
        }
        if ( mdOtherObjects.getId() != null ) {
            mdOtherObjectsDTO.setId( mdOtherObjects.getId().intValue() );
        }
        mdOtherObjectsDTO.setName( mdOtherObjects.getName() );
        mdOtherObjectsDTO.setNativeSql( mdOtherObjects.getNativeSql() );
        mdOtherObjectsDTO.setNativeKey( mdOtherObjects.getNativeKey() );
        mdOtherObjectsDTO.setComments( mdOtherObjects.getComments() );
        if ( mdOtherObjects.getSecurityGroupId() != null ) {
            mdOtherObjectsDTO.setSecurityGroupId( mdOtherObjects.getSecurityGroupId().intValue() );
        }
        mdOtherObjectsDTO.setCreatedOn( mdOtherObjects.getCreatedOn() );
        mdOtherObjectsDTO.setCreatedBy( mdOtherObjects.getCreatedBy() );
        mdOtherObjectsDTO.setLastUpdatedOn( mdOtherObjects.getLastUpdatedOn() );
        mdOtherObjectsDTO.setLastUpdatedBy( mdOtherObjects.getLastUpdatedBy() );

        return mdOtherObjectsDTO;
    }

    protected MdSchemas mdOtherObjectsDTOToMdSchemas(MdOtherObjectsDTO mdOtherObjectsDTO) {
        if ( mdOtherObjectsDTO == null ) {
            return null;
        }

        MdSchemas mdSchemas = new MdSchemas();

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

        return mdSchemas;
    }

    private BigDecimal mdOtherObjectsSchemaIdFkId(MdOtherObjects mdOtherObjects) {
        if ( mdOtherObjects == null ) {
            return null;
        }
        MdSchemas schemaIdFk = mdOtherObjects.getSchemaIdFk();
        if ( schemaIdFk == null ) {
            return null;
        }
        BigDecimal id = schemaIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
