From 0406818efc541c8a49a02e951b3f93137b566d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Muzik=C3=A1=C5=99?= Date: Mon, 18 Nov 2024 14:51:25 +0100 Subject: [PATCH] Revert "MappingFunction" This reverts commit e4f539f0446e81971a442e587cc76c3effa9d252. --- .../configuration/mappers/PropertyMapper.java | 34 +++++-------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/mappers/PropertyMapper.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/mappers/PropertyMapper.java index afa65410f810..8ca76bf0b83f 100644 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/mappers/PropertyMapper.java +++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/configuration/mappers/PropertyMapper.java @@ -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 mapper; private final String mapFrom; - private final MappingFunction parentMapper; + private final BiFunction parentMapper; private final boolean mask; private final String paramLabel; private final String envVarFormat; @@ -94,8 +94,8 @@ public ConfigValue getConfigValue(String name, ConfigSourceInterceptorContext co private final Pattern wildcardPattern; PropertyMapper(Option option, String to, BooleanSupplier enabled, String enabledWhen, - MappingFunction mapper, - String mapFrom, MappingFunction parentMapper, + BiFunction mapper, + String mapFrom, BiFunction parentMapper, String paramLabel, boolean mask, BiConsumer, ConfigValue> validator, String description, BooleanSupplier required, String requiredWhen) { this.option = option; @@ -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; } @@ -339,9 +339,9 @@ public static class Builder { private final Option option; private String to; - private MappingFunction mapper; + private BiFunction mapper; private String mapFrom = null; - private MappingFunction parentMapper; + private BiFunction parentMapper; private boolean isMasked = false; private BooleanSupplier isEnabled = () -> true; private String enabledWhen = ""; @@ -368,13 +368,8 @@ public Builder to(String to) { *

* The value passed into the transformer may be null if the property has no value set, and no default */ - public Builder transformer(MappingFunction mapper) { - this.mapper = mapper; - return this; - } - public Builder transformer(BiFunction mapper) { - this.mapper = (k, v, c) -> mapper.apply(v, c); + this.mapper = mapper; return this; } @@ -388,15 +383,9 @@ public Builder mapFrom(Option mapFrom) { return this; } - public Builder mapFrom(Option mapFrom, MappingFunction parentMapper) { - this.mapFrom = mapFrom.getKey(); - this.parentMapper = parentMapper; - return this; - } - public Builder mapFrom(Option mapFrom, BiFunction parentMapper) { this.mapFrom = mapFrom.getKey(); - this.parentMapper = (k, v, c) -> parentMapper.apply(v, c); + this.parentMapper = parentMapper; return this; } @@ -569,9 +558,4 @@ String getOptionAndSourceMessage(ConfigValue configValue) { KeycloakConfigSourceProvider.getConfigSourceDisplayName(configValue.getConfigSourceName())); } - @FunctionalInterface - public interface MappingFunction { - String map(String key, String value, ConfigSourceInterceptorContext context); - } - }