Skip to content

Commit 405c3dd

Browse files
committed
Improving code quality (reducing indentations) of withRegex() function outside builder.
1 parent 4376dab commit 405c3dd

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

orchestration/src/main/java/com/sap/ai/sdk/orchestration/DpiMasking.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,16 @@ public DpiMasking withRegex(@Nonnull final String regex, @Nonnull final String r
114114
*/
115115
@Nonnull
116116
public DpiMasking withRegex(@Nonnull final String regex, @Nonnull final String replacement) {
117-
return new DpiMasking(
118-
maskingMethod,
119-
Stream.concat(
120-
entitiesDTO.stream(),
121-
Stream.of(
122-
DPICustomEntity.create()
123-
.regex(regex)
124-
.replacementStrategy(
125-
DPIMethodConstant.create()
126-
.method(DPIMethodConstant.MethodEnum.CONSTANT)
127-
.value(replacement))))
128-
.toList(),
129-
maskGroundingInput,
130-
allowList);
117+
var customEntity =
118+
DPICustomEntity.create()
119+
.regex(regex)
120+
.replacementStrategy(
121+
DPIMethodConstant.create()
122+
.method(DPIMethodConstant.MethodEnum.CONSTANT)
123+
.value(replacement));
124+
var newEntities = new java.util.ArrayList<>(entitiesDTO);
125+
newEntities.add(customEntity);
126+
return new DpiMasking(maskingMethod, newEntities, maskGroundingInput, allowList);
131127
}
132128

133129
/**

0 commit comments

Comments
 (0)