| 1 |
import java.util.Collection; |
| 2 |
import java.util.Enumeration; |
| 3 |
import java.util.Iterator; |
| 4 |
import java.util.Map; |
| 5 |
import org.checkerframework.checker.nullness.qual.Nullable; |
| 6 |
import org.checkerframework.dataflow.qual.Pure; |
| 7 |
|
| 8 |
class Other { |
| 9 |
public static final class StaticIterator<T> implements Iterator<T> { |
| 10 |
Enumeration<T> e; |
| 11 |
|
| 12 |
public StaticIterator(Enumeration<T> e) { |
| 13 |
this.e = e; |
| 14 |
} |
| 15 |
|
| 16 |
public boolean hasNext() { |
| 17 |
return e.hasMoreElements(); |
| 18 |
} |
| 19 |
|
| 20 |
public T next() { |
| 21 |
return e.nextElement(); |
| 22 |
} |
| 23 |
|
| 24 |
public void remove() { |
| 25 |
throw new UnsupportedOperationException(); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
public final class FinalIterator<T> implements Iterator<T> { |
| 30 |
Enumeration<T> e; |
| 31 |
|
| 32 |
public FinalIterator(Enumeration<T> e) { |
| 33 |
this.e = e; |
| 34 |
} |
| 35 |
|
| 36 |
public boolean hasNext() { |
| 37 |
return e.hasMoreElements(); |
| 38 |
} |
| 39 |
|
| 40 |
public T next() { |
| 41 |
return e.nextElement(); |
| 42 |
} |
| 43 |
|
| 44 |
public void remove() { |
| 45 |
throw new UnsupportedOperationException(); |
| 46 |
} |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
class Entry<K, V> implements Map.Entry<K, V> { |
| 51 |
public V setValue(V newValue) { |
| 52 |
throw new RuntimeException(); |
| 53 |
} |
| 54 |
|
| 55 |
@SuppressWarnings("purity") // new and throw are not allowed, ignore |
| 56 |
@Pure |
| 57 |
public K getKey() { |
| 58 |
throw new RuntimeException(); |
| 59 |
} |
| 60 |
|
| 61 |
@SuppressWarnings("purity") // new and throw are not allowed, ignore |
| 62 |
@Pure |
| 63 |
public V getValue() { |
| 64 |
throw new RuntimeException(); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
interface Function<F, T extends @Nullable Object> { |
| 69 |
T apply(@Nullable F from); |
| 70 |
|
| 71 |
@Pure |
| 72 |
boolean equals(@Nullable Object obj); |
| 73 |
} |
| 74 |
|
| 75 |
enum IdentityFunction implements Function<Object, @Nullable Object> { |
| 76 |
INSTANCE; |
| 77 |
|
| 78 |
public @Nullable Object apply(@Nullable Object o) { |
| 79 |
return o; |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
abstract class FilteredCollection<E> implements Collection<E> { |
| 84 |
public boolean addAll(Collection<? extends E> collection) { |
| 85 |
for (E element : collection) {} |
| 86 |
return true; |
| 87 |
} |
| 88 |
} |