All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.brihaspathee.zeus.mapper.impl.MemberLanguageMapperImpl Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
package com.brihaspathee.zeus.mapper.impl;

import com.brihaspathee.zeus.domain.entity.MemberLanguage;
import com.brihaspathee.zeus.dto.account.MemberLanguageDto;
import com.brihaspathee.zeus.mapper.interfaces.MemberLanguageMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

/**
 * Created in Intellij IDEA
 * User: Balaji Varadharajan
 * Date: 30, November 2022
 * Time: 3:51 PM
 * Project: Zeus
 * Package Name: com.brihaspathee.zeus.mapper.impl
 * To change this template use File | Settings | File and Code Template
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class MemberLanguageMapperImpl implements MemberLanguageMapper {

    /**
     * Convert language entity to language dto
     * @param language
     * @return
     */
    @Override
    public MemberLanguageDto languageToLanguageDto(MemberLanguage language) {
        if(language == null){
            return null;
        }
        MemberLanguageDto languageDto = MemberLanguageDto.builder()
                .memberLanguageSK(language.getMemberAcctLangSK())
                .memberLanguageCode(language.getMemberLanguageCode())
                .languageTypeCode(language.getLanguageTypeCode())
                .languageCode(language.getLanguageCode())
                .ztcn(language.getZtcn())
                .source(language.getSource())
                .startDate(language.getStartDate())
                .endDate(language.getEndDate())
                .changed(new AtomicBoolean(language.isChanged()))
                .createdDate(language.getCreatedDate())
                .updatedDate(language.getUpdatedDate())
                .build();
        return languageDto;
    }

    /**
     * Convert language dto to language entity
     * @param languageDto
     * @return
     */
    @Override
    public MemberLanguage languageDtoToLanguage(MemberLanguageDto languageDto) {
        if(languageDto == null){
            return null;
        }
        MemberLanguage language = MemberLanguage.builder()
                .memberLanguageCode(languageDto.getMemberLanguageCode())
                .languageTypeCode(languageDto.getLanguageTypeCode())
                .languageCode(languageDto.getLanguageCode())
                .ztcn(languageDto.getZtcn())
                .source(languageDto.getSource())
                .startDate(languageDto.getStartDate())
                .endDate(languageDto.getEndDate())
                .createdDate(languageDto.getCreatedDate())
                .updatedDate(languageDto.getUpdatedDate())
                .build();
        if (languageDto.getChanged() != null){
            language.setChanged(languageDto.getChanged().get());
        } else {
            language.setChanged(false);
        }
        return language;
    }

    /**
     * Convert language entities to language dtos
     * @param languages
     * @return
     */
    @Override
    public List languagesToLanguageDtos(List languages) {
        return languages.stream().map(this::languageToLanguageDto).collect(Collectors.toList());
    }

    /**
     * Convert language dtos to language entities
     * @param languageDtos
     * @return
     */
    @Override
    public List languageDtosToLanguages(List languageDtos) {
        return languageDtos.stream().map(this::languageDtoToLanguage).collect(Collectors.toList());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy