|
|
@ -1122,7 +1122,8 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> { |
|
|
|
* Useful for implementing {@link Message.Builder#setField(Descriptors.FieldDescriptor, |
|
|
|
* Useful for implementing {@link Message.Builder#setField(Descriptors.FieldDescriptor, |
|
|
|
* Object)}. |
|
|
|
* Object)}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@SuppressWarnings({"unchecked", "rawtypes"}) |
|
|
|
// Avoid iterator allocation.
|
|
|
|
|
|
|
|
@SuppressWarnings({"unchecked", "ForeachList", "ForeachListWithUserVar"}) |
|
|
|
public void setField(final T descriptor, Object value) { |
|
|
|
public void setField(final T descriptor, Object value) { |
|
|
|
ensureIsMutable(); |
|
|
|
ensureIsMutable(); |
|
|
|
if (descriptor.isRepeated()) { |
|
|
|
if (descriptor.isRepeated()) { |
|
|
@ -1133,8 +1134,10 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> { |
|
|
|
|
|
|
|
|
|
|
|
// Wrap the contents in a new list so that the caller cannot change
|
|
|
|
// Wrap the contents in a new list so that the caller cannot change
|
|
|
|
// the list's contents after setting it.
|
|
|
|
// the list's contents after setting it.
|
|
|
|
final List newList = new ArrayList((List) value); |
|
|
|
final List<Object> newList = new ArrayList<>((List<Object>) value); |
|
|
|
for (final Object element : newList) { |
|
|
|
int newListSize = newList.size(); |
|
|
|
|
|
|
|
for (int i = 0; i < newListSize; i++) { |
|
|
|
|
|
|
|
Object element = newList.get(i); |
|
|
|
verifyType(descriptor, element); |
|
|
|
verifyType(descriptor, element); |
|
|
|
hasNestedBuilders = hasNestedBuilders || element instanceof MessageLite.Builder; |
|
|
|
hasNestedBuilders = hasNestedBuilders || element instanceof MessageLite.Builder; |
|
|
|
} |
|
|
|
} |
|
|
|