8170945: Collectors$Partition should override more Map methods
Reviewed-by: smarks
This commit is contained in:
parent
0826ceee65
commit
54bf370079
@ -1972,6 +1972,35 @@ public final class Collectors {
|
||||
this.forFalse = forFalse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(Object key) {
|
||||
if (key instanceof Boolean b) {
|
||||
return b ? forTrue : forFalse;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
return key instanceof Boolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
return Objects.equals(value, forTrue) || Objects.equals(value, forFalse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<Boolean, T>> entrySet() {
|
||||
return new AbstractSet<>() {
|
||||
|
Loading…
Reference in New Issue
Block a user