package com.oguerreiro.resilient.service.mapper;

import java.util.List;

import org.mapstruct.BeanMapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Named;
import org.mapstruct.NullValuePropertyMappingStrategy;

/**
 * Contract for a generic dto to entity mapper.
 *
 * @param <DTO> - Entity domain DTO class type parameter.
 * @param <T>   - Entity domain class type parameter.
 */

public interface ResilientEntityMapper<DTO, T> {
  T toEntity(DTO dto);

  DTO toDto(T entity);

  List<T> toEntity(List<DTO> dtoList);

  List<DTO> toDto(List<T> entityList);

  @Named("partialUpdate")
  @BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
  void partialUpdate(@MappingTarget T entity, DTO dto);
}
