1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.netty5.util.internal;
18
19 import java.util.Iterator;
20
21 import static java.util.Objects.requireNonNull;
22
23 public final class ReadOnlyIterator<T> implements Iterator<T> {
24 private final Iterator<? extends T> iterator;
25
26 public ReadOnlyIterator(Iterator<? extends T> iterator) {
27 requireNonNull(iterator, "iterator");
28 this.iterator = iterator;
29 }
30
31 @Override
32 public boolean hasNext() {
33 return iterator.hasNext();
34 }
35
36 @Override
37 public T next() {
38 return iterator.next();
39 }
40
41 @Override
42 public void remove() {
43 throw new UnsupportedOperationException("read-only");
44 }
45 }