Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect GuardianList#toString to the guarded list #5336

Merged
merged 1 commit into from
May 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,24 @@ public List<V> subList(int fromIndex, int toIndex) {
final List<V> sublist = guarded.subList(fromIndex, toIndex);
return sublist != null ? new GuardianList<>(sublist, guard) : sublist;
}

@Override
public String toString() {
return guarded.toString();
}

@Override
public boolean equals(Object obj) {
if (GuardianList.class.isInstance(obj)) {
return guarded.equals(((GuardianList) obj).guarded);
}
return guarded.equals(obj);
}

@Override
public int hashCode() {
return guarded.hashCode();
}
}

private static class GuardianIterator<V> extends MutableGuardian<V> implements Iterator<V> {
Expand Down Expand Up @@ -411,6 +429,11 @@ public void remove() {
public void forEachRemaining(Consumer<? super V> action) {
guarded.forEachRemaining(action);
}

@Override
public String toString() {
return guarded.toString();
}
}

private static class GuardianListIterator<V> extends GuardianIterator<V> implements ListIterator<V> {
Expand Down