com.osomapps.pt.admin.goal.AdminGoalTypeService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
dl 0
loc 17
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A AdminGoalTypeService(GoalTypeRepository) 0 2 1
A findAll() 0 4 1
A goalTypeToDto(GoalType) 0 2 1
1
package com.osomapps.pt.admin.goal;
2
3
import com.osomapps.pt.goals.GoalType;
4
import com.osomapps.pt.goals.GoalTypeRepository;
5
import java.util.List;
6
import java.util.stream.Collectors;
7
import org.springframework.stereotype.Service;
8
9
@Service
10
class AdminGoalTypeService {
11
12
    private final GoalTypeRepository goalTypeRepository;
13
14
    AdminGoalTypeService(GoalTypeRepository goalTypeRepository) {
15
        this.goalTypeRepository = goalTypeRepository;
16
    }
17
18
    List<GoalTypeResponseDTO> findAll() {
19
        return goalTypeRepository.findAll().stream()
20
                .map(AdminGoalTypeService::goalTypeToDto)
21
                .collect(Collectors.toList());
22
    }
23
24
    private static GoalTypeResponseDTO goalTypeToDto(GoalType type) {
25
        return GoalTypeResponseDTO.builder().id(type.getId()).name(type.getName()).build();
26
    }
27
}
28