Skip to content

Commit

Permalink
Revert "MappingFunction"
Browse files Browse the repository at this point in the history
This reverts commit e4f539f.
  • Loading branch information
vmuzikar committed Nov 18, 2024
1 parent e4f539f commit 0406818
Showing 1 changed file with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public ConfigValue getConfigValue(String name, ConfigSourceInterceptorContext co
private final String to;
private BooleanSupplier enabled;
private String enabledWhen;
private final MappingFunction mapper;
private final BiFunction<String, ConfigSourceInterceptorContext, String> mapper;
private final String mapFrom;
private final MappingFunction parentMapper;
private final BiFunction<String, ConfigSourceInterceptorContext, String> parentMapper;
private final boolean mask;
private final String paramLabel;
private final String envVarFormat;
Expand All @@ -94,8 +94,8 @@ public ConfigValue getConfigValue(String name, ConfigSourceInterceptorContext co
private final Pattern wildcardPattern;

PropertyMapper(Option<T> option, String to, BooleanSupplier enabled, String enabledWhen,
MappingFunction mapper,
String mapFrom, MappingFunction parentMapper,
BiFunction<String, ConfigSourceInterceptorContext, String> mapper,
String mapFrom, BiFunction<String, ConfigSourceInterceptorContext, String> parentMapper,
String paramLabel, boolean mask, BiConsumer<PropertyMapper<T>, ConfigValue> validator,
String description, BooleanSupplier required, String requiredWhen) {
this.option = option;
Expand Down Expand Up @@ -276,7 +276,7 @@ private ConfigValue transformValue(String name, ConfigValue configValue, ConfigS
boolean mapped = false;
var theMapper = parentValue ? this.parentMapper : this.mapper;
if (theMapper != null && (!name.equals(getFrom()) || parentValue)) {
mappedValue = theMapper.map(name, value, context);
mappedValue = theMapper.apply(value, context);
mapped = true;
}

Expand Down Expand Up @@ -339,9 +339,9 @@ public static class Builder<T> {

private final Option<T> option;
private String to;
private MappingFunction mapper;
private BiFunction<String, ConfigSourceInterceptorContext, String> mapper;
private String mapFrom = null;
private MappingFunction parentMapper;
private BiFunction<String, ConfigSourceInterceptorContext, String> parentMapper;
private boolean isMasked = false;
private BooleanSupplier isEnabled = () -> true;
private String enabledWhen = "";
Expand All @@ -368,13 +368,8 @@ public Builder<T> to(String to) {
* <p>
* The value passed into the transformer may be null if the property has no value set, and no default
*/
public Builder<T> transformer(MappingFunction mapper) {
this.mapper = mapper;
return this;
}

public Builder<T> transformer(BiFunction<String, ConfigSourceInterceptorContext, String> mapper) {
this.mapper = (k, v, c) -> mapper.apply(v, c);
this.mapper = mapper;
return this;
}

Expand All @@ -388,15 +383,9 @@ public Builder<T> mapFrom(Option<?> mapFrom) {
return this;
}

public Builder<T> mapFrom(Option<?> mapFrom, MappingFunction parentMapper) {
this.mapFrom = mapFrom.getKey();
this.parentMapper = parentMapper;
return this;
}

public Builder<T> mapFrom(Option<?> mapFrom, BiFunction<String, ConfigSourceInterceptorContext, String> parentMapper) {
this.mapFrom = mapFrom.getKey();
this.parentMapper = (k, v, c) -> parentMapper.apply(v, c);
this.parentMapper = parentMapper;
return this;
}

Expand Down Expand Up @@ -569,9 +558,4 @@ String getOptionAndSourceMessage(ConfigValue configValue) {
KeycloakConfigSourceProvider.getConfigSourceDisplayName(configValue.getConfigSourceName()));
}

@FunctionalInterface
public interface MappingFunction {
String map(String key, String value, ConfigSourceInterceptorContext context);
}

}

0 comments on commit 0406818

Please sign in to comment.