31 package com.google.protobuf;
34 import java.util.AbstractList;
35 import java.util.Collection;
36 import java.util.List;
37 import java.util.RandomAccess;
46 abstract class AbstractProtobufList<E>
extends AbstractList<E> implements ProtobufList<E> {
48 protected static final int DEFAULT_CAPACITY = 10;
51 private boolean isMutable;
54 AbstractProtobufList() {
59 public boolean equals(Object o) {
63 if (!(o instanceof List)) {
69 if (!(o instanceof RandomAccess)) {
70 return super.equals(o);
73 List<?> other = (List<?>) o;
75 if (
size != other.size()) {
78 for (
int i = 0;
i <
size;
i++) {
79 if (!
get(
i).equals(other.get(
i))) {
87 public int hashCode() {
90 for (
int i = 0;
i <
size;
i++) {
91 hashCode = (31 * hashCode) +
get(
i).hashCode();
97 public boolean add(E e) {
103 public void add(
int index, E element) {
105 super.add(
index, element);
109 public boolean addAll(Collection<? extends E> c) {
111 return super.addAll(c);
115 public boolean addAll(
int index, Collection<? extends E> c) {
117 return super.addAll(
index, c);
121 public void clear() {
127 public boolean isModifiable() {
132 public final void makeImmutable() {
137 public E
remove(
int index) {
139 return super.remove(
index);
143 public boolean remove(Object o) {
145 return super.remove(o);
149 public boolean removeAll(Collection<?> c) {
151 return super.removeAll(c);
155 public boolean retainAll(Collection<?> c) {
157 return super.retainAll(c);
161 public E
set(
int index, E element) {
163 return super.set(
index, element);
170 protected void ensureIsMutable() {
172 throw new UnsupportedOperationException();