package com.oguerreiro.resilient.service.mapper;

import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;

import com.oguerreiro.resilient.domain.Unit;
import com.oguerreiro.resilient.domain.UnitConverter;
import com.oguerreiro.resilient.domain.Variable;
import com.oguerreiro.resilient.domain.VariableUnits;
import com.oguerreiro.resilient.service.dto.UnitConverterDTO;
import com.oguerreiro.resilient.service.dto.UnitDTO;
import com.oguerreiro.resilient.service.dto.VariableDTO;
import com.oguerreiro.resilient.service.dto.VariableUnitsDTO;

/**
 * Mapper for the entity {@link VariableUnits} and its DTO {@link VariableUnitsDTO}.
 */
@Mapper(componentModel = "spring")
public interface VariableUnitsMapper extends ResilientEntityMapper<VariableUnitsDTO, VariableUnits> {
  @Mapping(target = "variable", source = "variable", qualifiedByName = "variableName")
  @Mapping(target = "unit", source = "unit", qualifiedByName = "unitName")
  @Mapping(target = "unitConverter", source = "unitConverter", qualifiedByName = "unitConverterName")
  VariableUnitsDTO toDto(VariableUnits s);

  @Named("variableName")
  @BeanMapping(ignoreByDefault = true)
  @Mapping(target = "id", source = "id")
  @Mapping(target = "name", source = "name")
  VariableDTO toDtoVariableName(Variable variable);

  @Named("unitName")
  @BeanMapping(ignoreByDefault = true)
  @Mapping(target = "id", source = "id")
  @Mapping(target = "name", source = "name")
  UnitDTO toDtoUnitName(Unit unit);

  @Named("unitConverterName")
  @BeanMapping(ignoreByDefault = true)
  @Mapping(target = "id", source = "id")
  @Mapping(target = "name", source = "name")
  UnitConverterDTO toDtoUnitConverterName(UnitConverter unitConverter);
}
