diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2018-09-07 16:15:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-07 16:15:38 -0700 |
commit | f9d8138376765d229a32635c9209061e4e4aed8c (patch) | |
tree | 50719686fd7262f405c9bda8694d6c72e7c038b8 /java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java | |
parent | 2e7563f40ec7f901ae8ae1cc749d701fa07e211d (diff) | |
parent | e53be9bce4556cf0d13e24f1a25a7d75f663144f (diff) | |
download | protobuf-f9d8138376765d229a32635c9209061e4e4aed8c.tar.gz protobuf-f9d8138376765d229a32635c9209061e4e4aed8c.tar.bz2 protobuf-f9d8138376765d229a32635c9209061e4e4aed8c.zip |
Merge pull request #5109 from haberman/integrate
Down-integrate from google3.
Diffstat (limited to 'java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java')
-rw-r--r-- | java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java b/java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java index 81255ec2..98341613 100644 --- a/java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java +++ b/java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java @@ -31,31 +31,29 @@ package com.google.protobuf; import com.google.protobuf.Internal.ProtobufList; - import java.util.ArrayList; import java.util.List; -/** - * Implements {@link ProtobufList} for non-primitive and {@link String} types. - */ +/** Implements {@link ProtobufList} for non-primitive and {@link String} types. */ final class ProtobufArrayList<E> extends AbstractProtobufList<E> { private static final ProtobufArrayList<Object> EMPTY_LIST = new ProtobufArrayList<Object>(); + static { EMPTY_LIST.makeImmutable(); } - + @SuppressWarnings("unchecked") // Guaranteed safe by runtime. public static <E> ProtobufArrayList<E> emptyList() { return (ProtobufArrayList<E>) EMPTY_LIST; } - + private final List<E> list; ProtobufArrayList() { this(new ArrayList<E>(DEFAULT_CAPACITY)); } - + private ProtobufArrayList(List<E> list) { this.list = list; } @@ -69,7 +67,7 @@ final class ProtobufArrayList<E> extends AbstractProtobufList<E> { newList.addAll(list); return new ProtobufArrayList<E>(newList); } - + @Override public void add(int index, E element) { ensureIsMutable(); @@ -81,7 +79,7 @@ final class ProtobufArrayList<E> extends AbstractProtobufList<E> { public E get(int index) { return list.get(index); } - + @Override public E remove(int index) { ensureIsMutable(); @@ -89,7 +87,7 @@ final class ProtobufArrayList<E> extends AbstractProtobufList<E> { modCount++; return toReturn; } - + @Override public E set(int index, E element) { ensureIsMutable(); |