Skip to content

Commit

Permalink
Redirect GuardianList#toString to the guarded list
Browse files Browse the repository at this point in the history
Signed-off-by: jansupol <jan.supol@oracle.com>
  • Loading branch information
jansupol authored and senivam committed May 17, 2023
1 parent b724eaa commit d583711
Showing 1 changed file with 23 additions and 0 deletions.
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

0 comments on commit d583711

Please sign in to comment.