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

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

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

    @Override
    public MdUserDefinedDataTypes getEntidad(MdUserDefinedDataTypesDTO mdUserDefinedDataTypes) {
        if ( mdUserDefinedDataTypes == null ) {
            return null;
        }

        MdUserDefinedDataTypes mdUserDefinedDataTypes1 = new MdUserDefinedDataTypes();

        mdUserDefinedDataTypes1.setSchemaIdFk( mdUserDefinedDataTypesDTOToMdSchemas( mdUserDefinedDataTypes ) );
        if ( mdUserDefinedDataTypes.getId() != null ) {
            mdUserDefinedDataTypes1.setId( BigDecimal.valueOf( mdUserDefinedDataTypes.getId() ) );
        }
        mdUserDefinedDataTypes1.setDataTypeName( mdUserDefinedDataTypes.getDataTypeName() );
        mdUserDefinedDataTypes1.setDefinition( mdUserDefinedDataTypes.getDefinition() );
        mdUserDefinedDataTypes1.setNativeSql( mdUserDefinedDataTypes.getNativeSql() );
        mdUserDefinedDataTypes1.setNativeKey( mdUserDefinedDataTypes.getNativeKey() );
        mdUserDefinedDataTypes1.setComments( mdUserDefinedDataTypes.getComments() );
        if ( mdUserDefinedDataTypes.getSecurityGroupId() != null ) {
            mdUserDefinedDataTypes1.setSecurityGroupId( BigInteger.valueOf( mdUserDefinedDataTypes.getSecurityGroupId() ) );
        }
        mdUserDefinedDataTypes1.setCreatedOn( mdUserDefinedDataTypes.getCreatedOn() );
        mdUserDefinedDataTypes1.setCreatedBy( mdUserDefinedDataTypes.getCreatedBy() );
        mdUserDefinedDataTypes1.setLastUpdatedOn( mdUserDefinedDataTypes.getLastUpdatedOn() );
        mdUserDefinedDataTypes1.setLastUpdatedBy( mdUserDefinedDataTypes.getLastUpdatedBy() );

        return mdUserDefinedDataTypes1;
    }

    @Override
    public MdUserDefinedDataTypesDTO getDto(MdUserDefinedDataTypes mdUserDefinedDataTypes) {
        if ( mdUserDefinedDataTypes == null ) {
            return null;
        }

        MdUserDefinedDataTypesDTO mdUserDefinedDataTypesDTO = new MdUserDefinedDataTypesDTO();

        BigDecimal id = mdUserDefinedDataTypesSchemaIdFkId( mdUserDefinedDataTypes );
        if ( id != null ) {
            mdUserDefinedDataTypesDTO.setSchemaIdFk( id.intValue() );
        }
        if ( mdUserDefinedDataTypes.getId() != null ) {
            mdUserDefinedDataTypesDTO.setId( mdUserDefinedDataTypes.getId().intValue() );
        }
        mdUserDefinedDataTypesDTO.setDataTypeName( mdUserDefinedDataTypes.getDataTypeName() );
        mdUserDefinedDataTypesDTO.setDefinition( mdUserDefinedDataTypes.getDefinition() );
        mdUserDefinedDataTypesDTO.setNativeSql( mdUserDefinedDataTypes.getNativeSql() );
        mdUserDefinedDataTypesDTO.setNativeKey( mdUserDefinedDataTypes.getNativeKey() );
        mdUserDefinedDataTypesDTO.setComments( mdUserDefinedDataTypes.getComments() );
        if ( mdUserDefinedDataTypes.getSecurityGroupId() != null ) {
            mdUserDefinedDataTypesDTO.setSecurityGroupId( mdUserDefinedDataTypes.getSecurityGroupId().intValue() );
        }
        mdUserDefinedDataTypesDTO.setCreatedOn( mdUserDefinedDataTypes.getCreatedOn() );
        mdUserDefinedDataTypesDTO.setCreatedBy( mdUserDefinedDataTypes.getCreatedBy() );
        mdUserDefinedDataTypesDTO.setLastUpdatedOn( mdUserDefinedDataTypes.getLastUpdatedOn() );
        mdUserDefinedDataTypesDTO.setLastUpdatedBy( mdUserDefinedDataTypes.getLastUpdatedBy() );

        return mdUserDefinedDataTypesDTO;
    }

    protected MdSchemas mdUserDefinedDataTypesDTOToMdSchemas(MdUserDefinedDataTypesDTO mdUserDefinedDataTypesDTO) {
        if ( mdUserDefinedDataTypesDTO == null ) {
            return null;
        }

        MdSchemas mdSchemas = new MdSchemas();

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

        return mdSchemas;
    }

    private BigDecimal mdUserDefinedDataTypesSchemaIdFkId(MdUserDefinedDataTypes mdUserDefinedDataTypes) {
        if ( mdUserDefinedDataTypes == null ) {
            return null;
        }
        MdSchemas schemaIdFk = mdUserDefinedDataTypes.getSchemaIdFk();
        if ( schemaIdFk == null ) {
            return null;
        }
        BigDecimal id = schemaIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
