| Total Complexity | 3 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package com.hltech.judged.server.domain.environment; |
||
| 12 | @Getter |
||
| 13 | @RequiredArgsConstructor |
||
| 14 | public class Environment { |
||
| 15 | |||
| 16 | public static final String DEFAULT_NAMESPACE = "default"; |
||
| 17 | |||
| 18 | private final String name; |
||
| 19 | private final Set<Space> spaces; |
||
| 20 | |||
| 21 | public Set<String> getSpaceNames() { |
||
| 22 | return spaces.stream() |
||
| 23 | .map(Space::getName) |
||
| 24 | .collect(Collectors.toUnmodifiableSet()); |
||
| 25 | } |
||
| 26 | |||
| 27 | public Set<ServiceId> getServices(String spaceName) { |
||
| 28 | return spaces.stream() |
||
| 29 | .filter(space -> space.getName().equals(spaceName)) |
||
| 30 | .findAny() |
||
| 31 | .map(Space::getServiceIds) |
||
| 32 | .orElse(new HashSet<>()); |
||
| 33 | } |
||
| 34 | |||
| 35 | public Set<ServiceId> getAllServices() { |
||
| 36 | return spaces.stream() |
||
| 37 | .flatMap(space -> space.getServiceIds().stream()) |
||
| 38 | .collect(Collectors.toUnmodifiableSet()); |
||
| 39 | } |
||
| 41 |