List<String> (@Nullable List<String> defaultActiveProfiles, @Nullable List<String> explicitActiveProfiles, @Nullable List<String> explicitInactiveProfiles) { if (defaultActiveProfiles == null || defaultActiveProfiles.isEmpty()) { return explicitActiveProfiles != null ? explicitActiveProfiles : Collections.emptyList(); } Set<String> result = new HashSet<>(defaultActiveProfiles); if (explicitInactiveProfiles != null && !explicitInactiveProfiles.isEmpty()) { result.removeAll(explicitInactiveProfiles); } if (explicitActiveProfiles != null) { result.addAll(explicitActiveProfiles); } return new ArrayList<>(result); }