-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add feature in JsonBodyFilters to replace value by custom function.
- Loading branch information
1 parent
279bed1
commit e582f8b
Showing
5 changed files
with
77 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
logbook-json/src/main/java/org/zalando/logbook/json/StaticParameterReplacementOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.zalando.logbook.json; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.EqualsAndHashCode; | ||
|
||
import java.util.function.BinaryOperator; | ||
|
||
import static org.zalando.logbook.json.PrimitiveJsonPropertyBodyFilter.quote; | ||
|
||
@AllArgsConstructor | ||
@EqualsAndHashCode | ||
public class StaticParameterReplacementOperator<T> implements BinaryOperator<String> { | ||
private final T replacement; | ||
|
||
private final boolean addQuotation; | ||
|
||
@Override | ||
public String apply(String s, String s2) { | ||
return addQuotation ? quote(replacement.toString()) : replacement.toString(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
logbook-json/src/main/java/org/zalando/logbook/json/StringFunctionReplacementOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.zalando.logbook.json; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.EqualsAndHashCode; | ||
|
||
import java.util.function.BiFunction; | ||
import java.util.function.BinaryOperator; | ||
|
||
import static org.zalando.logbook.json.PrimitiveJsonPropertyBodyFilter.quote; | ||
|
||
@AllArgsConstructor | ||
@EqualsAndHashCode | ||
public class StringFunctionReplacementOperator implements BinaryOperator<String> { | ||
private BiFunction<String, String, String> stringReplacementFunction; | ||
|
||
@Override | ||
public String apply(String s, String s2) { | ||
return quote(stringReplacementFunction.apply(s, s2)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters