Skip to content

Commit

Permalink
Add Condition.nullMatch (#347)
Browse files Browse the repository at this point in the history
* Add Condition.nullMatch

* fmt
  • Loading branch information
wsargent authored Dec 20, 2024
1 parent afdc6b6 commit a625eab
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions logging/src/main/java/echopraxia/logging/api/Condition.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ static Condition objectMatch(String fieldName, Predicate<Value<List<Field>>> pre
.map(f -> (Value.ObjectValue) f.value())
.anyMatch(predicate);
}

static Condition nullMatch(String fieldName) {
return (level, ctx) ->
ctx.getFields().stream()
.anyMatch(f -> f.name().equals(fieldName) && (f.value().type() == Value.Type.NULL));
}
}

class Conditions {
Expand Down

0 comments on commit a625eab

Please sign in to comment.