class KeyResultMapper implements DataMapper<KeyResult, KeyResultDto> {

  @Override
  public KeyResult mapDtoToEntity(KeyResultDto keyResultDto) {
    KeyResult keyResult = new KeyResult();

    keyResult.setId(keyResultDto.getId());
    keyResult.setName(keyResultDto.getTitle());
    keyResult.setDescription(keyResultDto.getDescription());
    keyResult.setUnit(keyResultDto.getUnit());
    keyResult.setStartValue(keyResultDto.getStartValue());
    keyResult.setCurrentValue(keyResultDto.getCurrentValue());
    keyResult.setTargetValue(keyResultDto.getTargetValue());
    keyResult.setSequence(keyResultDto.getSequence());

    Objective parentObjective = null;
    if (keyResultDto.getParentObjectiveId() != null) {
      parentObjective = new Objective();
      parentObjective.setId(keyResultDto.getParentObjectiveId());
    }
    keyResult.setParentObjective(parentObjective);

    keyResult.setNotes(new ArrayList<>());

    logger.info("Mapped KeyResultDto (id:" + keyResultDto.getNoteIds() + ") to KeyResult.");
    return keyResult;
  }

}