package com.oguerreiro.resilient.service.mapper;

import com.oguerreiro.resilient.domain.Unit;
import com.oguerreiro.resilient.domain.UnitConverter;
import com.oguerreiro.resilient.service.dto.UnitConverterDTO;
import com.oguerreiro.resilient.service.dto.UnitDTO;
import org.mapstruct.*;

/**
 * Mapper for the entity {@link UnitConverter} and its DTO {@link UnitConverterDTO}.
 */
@Mapper(componentModel = "spring")
public interface UnitConverterMapper extends ResilientEntityMapper<UnitConverterDTO, UnitConverter> {
    @Mapping(target = "fromUnit", source = "fromUnit", qualifiedByName = "unitName")
    @Mapping(target = "toUnit", source = "toUnit", qualifiedByName = "unitName")
    UnitConverterDTO toDto(UnitConverter s);

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