Skip to content

Commit

Permalink
Hacking
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Dec 13, 2021
1 parent 32ecbb8 commit 301d465
Showing 1 changed file with 19 additions and 1 deletion.
Expand Up @@ -21,6 +21,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

import javax.sql.DataSource;

Expand Down Expand Up @@ -92,6 +93,23 @@ public PlatformPlaceholderDatabaseDriverResolver withDriverPlatform(DatabaseDriv
*/
public List<String> resolveAll(DataSource dataSource, String... values) {
Assert.notNull(dataSource, "DataSource must not be null");
return resolveAll(() -> determinePlatform(dataSource), values);
}

/**
* Resolves the placeholders in the given {@code values}, replacing them with the
* given platform
* @param platform the platform to use
* @param values the values in which placeholders are resolved
* @return the values with their placeholders resolved
* @since 2.6.2
*/
public List<String> resolveAll(String platform, String... values) {
Assert.notNull(platform, "Platform must not be null");
return resolveAll(() -> platform, values);
}

private List<String> resolveAll(Supplier<String> platformProvider, String... values) {
if (ObjectUtils.isEmpty(values)) {
return Collections.emptyList();
}
Expand All @@ -100,7 +118,7 @@ public List<String> resolveAll(DataSource dataSource, String... values) {
for (String value : values) {
if (StringUtils.hasLength(value)) {
if (value.contains(this.placeholder)) {
platform = (platform != null) ? platform : determinePlatform(dataSource);
platform = (platform != null) ? platform : platformProvider.get();
value = value.replace(this.placeholder, platform);
}
}
Expand Down

0 comments on commit 301d465

Please sign in to comment.