[transform] Code optimization for Java17: instanceof matching and multiline strings (#15483)

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich
2023-08-24 06:41:36 +02:00
committed by GitHub
parent db651f9e92
commit 6e49c6e6ec
13 changed files with 111 additions and 107 deletions

View File

@@ -68,8 +68,8 @@ public class JSonPathTransformationService implements TransformationService {
logger.debug("transformation resulted in '{}'", transformationResult);
if (transformationResult == null) {
return null;
} else if (transformationResult instanceof List) {
return flattenList((List<?>) transformationResult);
} else if (transformationResult instanceof List list) {
return flattenList(list);
} else {
return transformationResult.toString();
}

View File

@@ -66,9 +66,9 @@ public class JSonPathTransformationProfile implements StateProfile {
if (paramSource == null) {
paramSource = "%s";
}
if (paramFunction instanceof String && paramSource instanceof String) {
function = (String) paramFunction;
sourceFormat = (String) paramSource;
if (paramFunction instanceof String pFunction && paramSource instanceof String pFormat) {
function = pFunction;
sourceFormat = pFormat;
} else {
logger.error("Parameter '{}' and '{}' have to be Strings. Profile will be inactive.", FUNCTION_PARAM,
SOURCE_FORMAT_PARAM);