package vn.azteam.tpf.service.mapper;

import vn.azteam.tpf.domain.*;
import vn.azteam.tpf.service.dto.TBObjectUpdateDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity TBObjectUpdate and its DTO TBObjectUpdateDTO.
 */
@Mapper(componentModel = "spring", uses = {TBObjectParameterMapper.class, TBActivityMapper.class})
public interface TBObjectUpdateMapper extends EntityMapper<TBObjectUpdateDTO, TBObjectUpdate> {

    @Mapping(source = "tbObjectParameter.id", target = "tbObjectParameterId")
    @Mapping(source = "tbActivity.id", target = "tbActivityId")
    @Mapping(source = "tbObjectParameter",target = "tbObjectParameterDTO")
    TBObjectUpdateDTO toDto(TBObjectUpdate tBObjectUpdate);

    @Mapping(source = "tbObjectParameterId", target = "tbObjectParameter")
    @Mapping(source = "tbActivityId", target = "tbActivity")
    TBObjectUpdate toEntity(TBObjectUpdateDTO tBObjectUpdateDTO);

    default TBObjectUpdate fromId(Long id) {
        if (id == null) {
            return null;
        }
        TBObjectUpdate tBObjectUpdate = new TBObjectUpdate();
        tBObjectUpdate.setId(id);
        return tBObjectUpdate;
    }
}
