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

import com.qsoft.rs.sincoar.dto.MigrDatatypeTransformRuleDTO;
import com.qsoft.rs.sincoar.model.MigrDatatypeTransformMap;
import com.qsoft.rs.sincoar.model.MigrDatatypeTransformRule;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.annotation.processing.Generated;

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

    @Override
    public MigrDatatypeTransformRule getEntidad(MigrDatatypeTransformRuleDTO migrDatatypeTransformRule) {
        if ( migrDatatypeTransformRule == null ) {
            return null;
        }

        MigrDatatypeTransformRule migrDatatypeTransformRule1 = new MigrDatatypeTransformRule();

        migrDatatypeTransformRule1.setMapIdFk( migrDatatypeTransformRuleDTOToMigrDatatypeTransformMap( migrDatatypeTransformRule ) );
        if ( migrDatatypeTransformRule.getId() != null ) {
            migrDatatypeTransformRule1.setId( BigDecimal.valueOf( migrDatatypeTransformRule.getId() ) );
        }
        migrDatatypeTransformRule1.setSourceDataTypeName( migrDatatypeTransformRule.getSourceDataTypeName() );
        if ( migrDatatypeTransformRule.getSourcePrecision() != null ) {
            migrDatatypeTransformRule1.setSourcePrecision( BigInteger.valueOf( migrDatatypeTransformRule.getSourcePrecision() ) );
        }
        if ( migrDatatypeTransformRule.getSourceScale() != null ) {
            migrDatatypeTransformRule1.setSourceScale( BigInteger.valueOf( migrDatatypeTransformRule.getSourceScale() ) );
        }
        migrDatatypeTransformRule1.setTargetDataTypeName( migrDatatypeTransformRule.getTargetDataTypeName() );
        if ( migrDatatypeTransformRule.getTargetPrecision() != null ) {
            migrDatatypeTransformRule1.setTargetPrecision( BigInteger.valueOf( migrDatatypeTransformRule.getTargetPrecision() ) );
        }
        if ( migrDatatypeTransformRule.getTargetScale() != null ) {
            migrDatatypeTransformRule1.setTargetScale( BigInteger.valueOf( migrDatatypeTransformRule.getTargetScale() ) );
        }
        if ( migrDatatypeTransformRule.getSecurityGroupId() != null ) {
            migrDatatypeTransformRule1.setSecurityGroupId( BigInteger.valueOf( migrDatatypeTransformRule.getSecurityGroupId() ) );
        }
        migrDatatypeTransformRule1.setCreatedOn( migrDatatypeTransformRule.getCreatedOn() );
        migrDatatypeTransformRule1.setCreatedBy( migrDatatypeTransformRule.getCreatedBy() );
        migrDatatypeTransformRule1.setLastUpdatedOn( migrDatatypeTransformRule.getLastUpdatedOn() );
        migrDatatypeTransformRule1.setLastUpdatedBy( migrDatatypeTransformRule.getLastUpdatedBy() );

        return migrDatatypeTransformRule1;
    }

    @Override
    public MigrDatatypeTransformRuleDTO getDto(MigrDatatypeTransformRule migrDatatypeTransformRule) {
        if ( migrDatatypeTransformRule == null ) {
            return null;
        }

        MigrDatatypeTransformRuleDTO migrDatatypeTransformRuleDTO = new MigrDatatypeTransformRuleDTO();

        BigDecimal id = migrDatatypeTransformRuleMapIdFkId( migrDatatypeTransformRule );
        if ( id != null ) {
            migrDatatypeTransformRuleDTO.setMapIdFk( id.intValue() );
        }
        if ( migrDatatypeTransformRule.getId() != null ) {
            migrDatatypeTransformRuleDTO.setId( migrDatatypeTransformRule.getId().intValue() );
        }
        migrDatatypeTransformRuleDTO.setSourceDataTypeName( migrDatatypeTransformRule.getSourceDataTypeName() );
        if ( migrDatatypeTransformRule.getSourcePrecision() != null ) {
            migrDatatypeTransformRuleDTO.setSourcePrecision( migrDatatypeTransformRule.getSourcePrecision().intValue() );
        }
        if ( migrDatatypeTransformRule.getSourceScale() != null ) {
            migrDatatypeTransformRuleDTO.setSourceScale( migrDatatypeTransformRule.getSourceScale().intValue() );
        }
        migrDatatypeTransformRuleDTO.setTargetDataTypeName( migrDatatypeTransformRule.getTargetDataTypeName() );
        if ( migrDatatypeTransformRule.getTargetPrecision() != null ) {
            migrDatatypeTransformRuleDTO.setTargetPrecision( migrDatatypeTransformRule.getTargetPrecision().intValue() );
        }
        if ( migrDatatypeTransformRule.getTargetScale() != null ) {
            migrDatatypeTransformRuleDTO.setTargetScale( migrDatatypeTransformRule.getTargetScale().intValue() );
        }
        if ( migrDatatypeTransformRule.getSecurityGroupId() != null ) {
            migrDatatypeTransformRuleDTO.setSecurityGroupId( migrDatatypeTransformRule.getSecurityGroupId().intValue() );
        }
        migrDatatypeTransformRuleDTO.setCreatedOn( migrDatatypeTransformRule.getCreatedOn() );
        migrDatatypeTransformRuleDTO.setCreatedBy( migrDatatypeTransformRule.getCreatedBy() );
        migrDatatypeTransformRuleDTO.setLastUpdatedOn( migrDatatypeTransformRule.getLastUpdatedOn() );
        migrDatatypeTransformRuleDTO.setLastUpdatedBy( migrDatatypeTransformRule.getLastUpdatedBy() );

        return migrDatatypeTransformRuleDTO;
    }

    protected MigrDatatypeTransformMap migrDatatypeTransformRuleDTOToMigrDatatypeTransformMap(MigrDatatypeTransformRuleDTO migrDatatypeTransformRuleDTO) {
        if ( migrDatatypeTransformRuleDTO == null ) {
            return null;
        }

        MigrDatatypeTransformMap migrDatatypeTransformMap = new MigrDatatypeTransformMap();

        if ( migrDatatypeTransformRuleDTO.getMapIdFk() != null ) {
            migrDatatypeTransformMap.setId( BigDecimal.valueOf( migrDatatypeTransformRuleDTO.getMapIdFk() ) );
        }

        return migrDatatypeTransformMap;
    }

    private BigDecimal migrDatatypeTransformRuleMapIdFkId(MigrDatatypeTransformRule migrDatatypeTransformRule) {
        if ( migrDatatypeTransformRule == null ) {
            return null;
        }
        MigrDatatypeTransformMap mapIdFk = migrDatatypeTransformRule.getMapIdFk();
        if ( mapIdFk == null ) {
            return null;
        }
        BigDecimal id = mapIdFk.getId();
        if ( id == null ) {
            return null;
        }
        return id;
    }
}
