[MAP] Adds fallback to original value when input not found (#13560)
* [MAP] Adding fallback to original value Solves #10092 Signed-off-by: clinique <gael@lhopital.org>
This commit is contained in:
@@ -52,12 +52,12 @@ import org.slf4j.LoggerFactory;
|
||||
"openhab.transform=MAP" })
|
||||
public class MapTransformationService
|
||||
implements TransformationService, ConfigOptionProvider, RegistryChangeListener<Transformation> {
|
||||
private final Logger logger = LoggerFactory.getLogger(MapTransformationService.class);
|
||||
|
||||
private static final String SOURCE_VALUE = "_source_";
|
||||
private static final String PROFILE_CONFIG_URI = "profile:transform:MAP";
|
||||
private static final String CONFIG_PARAM_FUNCTION = "function";
|
||||
private static final Set<String> SUPPORTED_CONFIGURATION_TYPES = Set.of("map");
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(MapTransformationService.class);
|
||||
private final TransformationRegistry transformationRegistry;
|
||||
private final Map<String, Properties> cachedTransformations = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -89,6 +89,8 @@ public class MapTransformationService
|
||||
target = properties.getProperty("");
|
||||
if (target == null) {
|
||||
throw new TransformationException("Target value not found in map for '" + source + "'");
|
||||
} else if (SOURCE_VALUE.equals(target)) {
|
||||
target = source;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user