MCPcopy Create free account
hub / github.com/davidgiven/luje / UnmodifiableCollection

Class UnmodifiableCollection

lib/java/util/Collections.java:968–1048  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

966 }
967
968 private static class UnmodifiableCollection<E> implements Collection<E>,
969 Serializable {
970 private static final long serialVersionUID = 1820017752578914078L;
971
972 final Collection<E> c;
973
974 UnmodifiableCollection(Collection<E> collection) {
975 c = collection;
976 }
977
978 public boolean add(E object) {
979 throw new UnsupportedOperationException();
980 }
981
982 public boolean addAll(Collection<? extends E> collection) {
983 throw new UnsupportedOperationException();
984 }
985
986 public void clear() {
987 throw new UnsupportedOperationException();
988 }
989
990 public boolean contains(Object object) {
991 return c.contains(object);
992 }
993
994 public boolean containsAll(Collection<?> collection) {
995 return c.containsAll(collection);
996 }
997
998 public boolean isEmpty() {
999 return c.isEmpty();
1000 }
1001
1002 public Iterator<E> iterator() {
1003 return new Iterator<E>() {
1004 Iterator<E> iterator = c.iterator();
1005
1006 public boolean hasNext() {
1007 return iterator.hasNext();
1008 }
1009
1010 public E next() {
1011 return iterator.next();
1012 }
1013
1014 public void remove() {
1015 throw new UnsupportedOperationException();
1016 }
1017 };
1018 }
1019
1020 public boolean remove(Object object) {
1021 throw new UnsupportedOperationException();
1022 }
1023
1024 public boolean removeAll(Collection<?> collection) {
1025 throw new UnsupportedOperationException();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected