package com.oguerreiro.resilient.service.mapper;

import com.oguerreiro.resilient.domain.Unit;
import com.oguerreiro.resilient.domain.UnitType;
import com.oguerreiro.resilient.service.dto.UnitDTO;
import com.oguerreiro.resilient.service.dto.UnitTypeDTO;
import org.mapstruct.*;

/**
 * Mapper for the entity {@link Unit} and its DTO {@link UnitDTO}.
 */
@Mapper(componentModel = "spring")
public interface UnitMapper extends ResilientEntityMapper<UnitDTO, Unit> {
    @Mapping(target = "unitType", source = "unitType", qualifiedByName = "unitTypeName")
    UnitDTO toDto(Unit s);

    @Named("unitTypeName")
    @BeanMapping(ignoreByDefault = true)
    @Mapping(target = "id", source = "id")
    @Mapping(target = "name", source = "name")
    @Mapping(target = "version", source = "version")
    UnitTypeDTO toDtoUnitTypeName(UnitType unitType);
}
