1 package pk.lucidxpo.ynami.utils;
2
3 import org.springframework.beans.factory.annotation.Value;
4 import org.springframework.stereotype.Component;
5
6 import java.util.Set;
7 import java.util.stream.Collectors;
8
9 import static java.util.Arrays.stream;
10
11 @Component
12 public class ProfileManager {
13 private final Set<String> activeProfiles;
14
15 public ProfileManager(@Value("${spring.profiles.active:}") final String activeProfiles) {
16 this.activeProfiles = stream(activeProfiles.toLowerCase().split(",")).collect(Collectors.toSet());
17 }
18
19 public boolean isH2Active() {
20 return isActive("H2");
21 }
22
23 @SuppressWarnings("SameParameterValue")
24 private boolean isActive(final String profile) {
25 return activeProfiles.contains(profile.toLowerCase());
26 }
27 }