Replace Function<String, String> with UnaryOperator<String>
See gh-38390
This commit is contained in:
parent
b296ff890e
commit
6f3b3fa6f6
|
@ -22,8 +22,8 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -84,7 +84,7 @@ public final class CorrelationIdFormatter {
|
|||
* @param resolver the resolver used to resolve named values
|
||||
* @return a formatted correlation id
|
||||
*/
|
||||
public String format(Function<String, String> resolver) {
|
||||
public String format(UnaryOperator<String> resolver) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
formatTo(resolver, result);
|
||||
return result.toString();
|
||||
|
@ -96,7 +96,7 @@ public final class CorrelationIdFormatter {
|
|||
* @param resolver the resolver used to resolve named values
|
||||
* @param appendable the appendable for the formatted correlation id
|
||||
*/
|
||||
public void formatTo(Function<String, String> resolver, Appendable appendable) {
|
||||
public void formatTo(UnaryOperator<String> resolver, Appendable appendable) {
|
||||
Predicate<Part> canResolve = (part) -> StringUtils.hasLength(resolver.apply(part.name()));
|
||||
try {
|
||||
if (this.parts.stream().anyMatch(canResolve)) {
|
||||
|
@ -169,7 +169,7 @@ public final class CorrelationIdFormatter {
|
|||
|
||||
private static final Pattern pattern = Pattern.compile("^(.+?)\\((\\d+)\\)$");
|
||||
|
||||
String resolve(Function<String, String> resolver) {
|
||||
String resolve(UnaryOperator<String> resolver) {
|
||||
String resolved = resolver.apply(name());
|
||||
if (resolved == null) {
|
||||
return blank();
|
||||
|
|
Loading…
Reference in New Issue