Skip to content

Commit bd21a5c

Browse files
committed
Refactpr boolean statements into an expression.
Javadoc
1 parent 8251348 commit bd21a5c

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

src/main/java/org/apache/commons/io/serialization/ObjectStreamClassPredicate.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@
3636
*/
3737
public class ObjectStreamClassPredicate implements Predicate<ObjectStreamClass> {
3838

39-
// This is not a Set for now to avoid ClassNameMatchers requiring proper implementations of hashCode() and equals().
39+
/**
40+
* This is not a Set for now to avoid ClassNameMatchers requiring proper implementations of hashCode() and equals().
41+
*/
4042
private final List<ClassNameMatcher> acceptMatchers = new ArrayList<>();
4143

42-
// This is not a Set for now to avoid ClassNameMatchers requiring proper implementations of hashCode() and equals().
44+
/**
45+
* This is not a Set for now to avoid ClassNameMatchers requiring proper implementations of hashCode() and equals().
46+
*/
4347
private final List<ClassNameMatcher> rejectMatchers = new ArrayList<>();
4448

4549
/**
@@ -188,17 +192,8 @@ public boolean test(final ObjectStreamClass objectStreamClass) {
188192
*/
189193
public boolean test(final String name) {
190194
// The reject list takes precedence over the accept list.
191-
for (final ClassNameMatcher m : rejectMatchers) {
192-
if (m.matches(name)) {
193-
return false;
194-
}
195-
}
196-
for (final ClassNameMatcher m : acceptMatchers) {
197-
if (m.matches(name)) {
198-
return true;
199-
}
200-
}
201-
return false;
195+
final Predicate<ClassNameMatcher> p = m -> m.matches(name);
196+
return rejectMatchers.stream().noneMatch(p) && acceptMatchers.stream().anyMatch(p);
202197
}
203198

204199
}

0 commit comments

Comments
 (0)