|
|
|
@ -731,7 +731,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
if (field.isRepeated()) { |
|
|
|
|
// The underlying list object is still modifiable at this point.
|
|
|
|
|
// Make sure not to expose the modifiable list to the caller.
|
|
|
|
|
return Collections.unmodifiableList((List) object); |
|
|
|
|
return Collections.unmodifiableList((List<?>) object); |
|
|
|
|
} else { |
|
|
|
|
return object; |
|
|
|
|
} |
|
|
|
@ -956,7 +956,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
// Extensions-related stuff
|
|
|
|
|
|
|
|
|
|
/** Extends {@link MessageOrBuilder} with extension-related functions. */ |
|
|
|
|
public interface ExtendableMessageOrBuilder<MessageT extends ExtendableMessage> |
|
|
|
|
public interface ExtendableMessageOrBuilder<MessageT extends ExtendableMessage<MessageT>> |
|
|
|
|
extends MessageOrBuilder { |
|
|
|
|
// Re-define for return type covariance.
|
|
|
|
|
@Override |
|
|
|
@ -1058,7 +1058,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
* |
|
|
|
|
* <p>See also {@link ExtendableBuilder}. |
|
|
|
|
*/ |
|
|
|
|
public abstract static class ExtendableMessage<MessageT extends ExtendableMessage> |
|
|
|
|
public abstract static class ExtendableMessage<MessageT extends ExtendableMessage<MessageT>> |
|
|
|
|
extends GeneratedMessageV3 implements ExtendableMessageOrBuilder<MessageT> { |
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L; |
|
|
|
@ -1088,7 +1088,6 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
|
|
|
|
|
/** Check if a singular extension is present. */ |
|
|
|
|
@Override |
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
public final <T> boolean hasExtension(final ExtensionLite<MessageT, T> extensionLite) { |
|
|
|
|
Extension<MessageT, T> extension = checkNotLite(extensionLite); |
|
|
|
|
|
|
|
|
@ -1098,7 +1097,6 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
|
|
|
|
|
/** Get the number of elements in a repeated extension. */ |
|
|
|
|
@Override |
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
public final <T> int getExtensionCount(final ExtensionLite<MessageT, List<T>> extensionLite) { |
|
|
|
|
Extension<MessageT, List<T>> extension = checkNotLite(extensionLite); |
|
|
|
|
|
|
|
|
@ -1455,7 +1453,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
*/ |
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
public abstract static class ExtendableBuilder< |
|
|
|
|
MessageT extends ExtendableMessage, |
|
|
|
|
MessageT extends ExtendableMessage<MessageT>, |
|
|
|
|
BuilderT extends ExtendableBuilder<MessageT, BuilderT>> |
|
|
|
|
extends Builder<BuilderT> implements ExtendableMessageOrBuilder<MessageT> { |
|
|
|
|
|
|
|
|
@ -1591,8 +1589,8 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** Clear an extension. */ |
|
|
|
|
public final BuilderT clearExtension(final ExtensionLite<MessageT, ?> extensionLite) { |
|
|
|
|
Extension<MessageT, ?> extension = checkNotLite(extensionLite); |
|
|
|
|
public final <T> BuilderT clearExtension(final ExtensionLite<MessageT, T> extensionLite) { |
|
|
|
|
Extension<MessageT, T> extension = checkNotLite(extensionLite); |
|
|
|
|
|
|
|
|
|
verifyExtensionContainingType(extension); |
|
|
|
|
ensureExtensionsIsMutable(); |
|
|
|
@ -1725,16 +1723,16 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
* <p>TODO(b/258340024): handled by ExtensionLite version |
|
|
|
|
*/ |
|
|
|
|
public final <T> BuilderT clearExtension( |
|
|
|
|
final Extension<MessageT, ?> extension) { |
|
|
|
|
return clearExtension((ExtensionLite<MessageT, ?>) extension); |
|
|
|
|
final Extension<MessageT, T> extension) { |
|
|
|
|
return clearExtension((ExtensionLite<MessageT, T>) extension); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* Clear an extension. |
|
|
|
|
* Clears an extension. |
|
|
|
|
* <p>TODO(b/258340024): handled by ExtensionLite version |
|
|
|
|
*/ |
|
|
|
|
public <T> BuilderT clearExtension( |
|
|
|
|
final GeneratedExtension<MessageT, ?> extension) { |
|
|
|
|
return clearExtension((ExtensionLite<MessageT, ?>) extension); |
|
|
|
|
final GeneratedExtension<MessageT, T> extension) { |
|
|
|
|
return clearExtension((ExtensionLite<MessageT, T>) extension); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** Called by subclasses to check if all extensions are initialized. */ |
|
|
|
@ -1943,7 +1941,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected final void mergeExtensionFields(final ExtendableMessage other) { |
|
|
|
|
protected final void mergeExtensionFields(final ExtendableMessage<?> other) { |
|
|
|
|
if (other.extensions != null) { |
|
|
|
|
ensureExtensionsIsMutable(); |
|
|
|
|
extensions.mergeFrom(other.extensions); |
|
|
|
@ -1985,9 +1983,8 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
// =================================================================
|
|
|
|
|
|
|
|
|
|
/** Calls Class.getMethod and throws a RuntimeException if it fails. */ |
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
private static Method getMethodOrDie( |
|
|
|
|
final Class clazz, final String name, final Class... params) { |
|
|
|
|
final Class<?> clazz, final String name, final Class<?>... params) { |
|
|
|
|
try { |
|
|
|
|
return clazz.getMethod(name, params); |
|
|
|
|
} catch (NoSuchMethodException e) { |
|
|
|
@ -2055,7 +2052,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
final Descriptor descriptor, |
|
|
|
|
final String[] camelCaseNames, |
|
|
|
|
final Class<? extends GeneratedMessageV3> messageClass, |
|
|
|
|
final Class<? extends Builder> builderClass) { |
|
|
|
|
final Class<? extends Builder<?>> builderClass) { |
|
|
|
|
this(descriptor, camelCaseNames); |
|
|
|
|
ensureFieldAccessorsInitialized(messageClass, builderClass); |
|
|
|
|
} |
|
|
|
@ -2080,7 +2077,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
* @return this |
|
|
|
|
*/ |
|
|
|
|
public FieldAccessorTable ensureFieldAccessorsInitialized( |
|
|
|
|
Class<? extends GeneratedMessageV3> messageClass, Class<? extends Builder> builderClass) { |
|
|
|
|
Class<? extends GeneratedMessageV3> messageClass, Class<? extends Builder<?>> builderClass) { |
|
|
|
|
if (initialized) { |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
@ -2195,35 +2192,29 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
private interface FieldAccessor { |
|
|
|
|
Object get(GeneratedMessageV3 message); |
|
|
|
|
|
|
|
|
|
Object get(GeneratedMessageV3.Builder builder); |
|
|
|
|
Object get(GeneratedMessageV3.Builder<?> builder); |
|
|
|
|
|
|
|
|
|
Object getRaw(GeneratedMessageV3 message); |
|
|
|
|
|
|
|
|
|
Object getRaw(GeneratedMessageV3.Builder builder); |
|
|
|
|
|
|
|
|
|
void set(Builder builder, Object value); |
|
|
|
|
void set(Builder<?> builder, Object value); |
|
|
|
|
|
|
|
|
|
Object getRepeated(GeneratedMessageV3 message, int index); |
|
|
|
|
|
|
|
|
|
Object getRepeated(GeneratedMessageV3.Builder builder, int index); |
|
|
|
|
|
|
|
|
|
Object getRepeatedRaw(GeneratedMessageV3 message, int index); |
|
|
|
|
Object getRepeated(GeneratedMessageV3.Builder<?> builder, int index); |
|
|
|
|
|
|
|
|
|
Object getRepeatedRaw(GeneratedMessageV3.Builder builder, int index); |
|
|
|
|
void setRepeated(Builder<?> builder, int index, Object value); |
|
|
|
|
|
|
|
|
|
void setRepeated(Builder builder, int index, Object value); |
|
|
|
|
|
|
|
|
|
void addRepeated(Builder builder, Object value); |
|
|
|
|
void addRepeated(Builder<?> builder, Object value); |
|
|
|
|
|
|
|
|
|
boolean has(GeneratedMessageV3 message); |
|
|
|
|
|
|
|
|
|
boolean has(GeneratedMessageV3.Builder builder); |
|
|
|
|
boolean has(GeneratedMessageV3.Builder<?> builder); |
|
|
|
|
|
|
|
|
|
int getRepeatedCount(GeneratedMessageV3 message); |
|
|
|
|
|
|
|
|
|
int getRepeatedCount(GeneratedMessageV3.Builder builder); |
|
|
|
|
int getRepeatedCount(GeneratedMessageV3.Builder<?> builder); |
|
|
|
|
|
|
|
|
|
void clear(Builder builder); |
|
|
|
|
void clear(Builder<?> builder); |
|
|
|
|
|
|
|
|
|
Message.Builder newBuilder(); |
|
|
|
|
|
|
|
|
@ -2239,7 +2230,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
final int oneofIndex, |
|
|
|
|
final String camelCaseName, |
|
|
|
|
final Class<? extends GeneratedMessageV3> messageClass, |
|
|
|
|
final Class<? extends Builder> builderClass) { |
|
|
|
|
final Class<? extends Builder<?>> builderClass) { |
|
|
|
|
this.descriptor = descriptor; |
|
|
|
|
OneofDescriptor oneofDescriptor = descriptor.getOneofs().get(oneofIndex); |
|
|
|
|
if (oneofDescriptor.isSynthetic()) { |
|
|
|
@ -2268,7 +2259,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean has(GeneratedMessageV3.Builder builder) { |
|
|
|
|
public boolean has(GeneratedMessageV3.Builder<?> builder) { |
|
|
|
|
if (fieldDescriptor != null) { |
|
|
|
|
return builder.hasField(fieldDescriptor); |
|
|
|
|
} else { |
|
|
|
@ -2288,7 +2279,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public FieldDescriptor get(GeneratedMessageV3.Builder builder) { |
|
|
|
|
public FieldDescriptor get(GeneratedMessageV3.Builder<?> builder) { |
|
|
|
|
if (fieldDescriptor != null) { |
|
|
|
|
return builder.hasField(fieldDescriptor) ? fieldDescriptor : null; |
|
|
|
|
} else { |
|
|
|
@ -2301,7 +2292,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void clear(final Builder builder) { |
|
|
|
|
public void clear(final Builder<?> builder) { |
|
|
|
|
// TODO(b/230609037): remove the unused variable
|
|
|
|
|
Object unused = invokeOrDie(clearMethod, builder); |
|
|
|
|
} |
|
|
|
@ -2342,7 +2333,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
final FieldDescriptor descriptor, |
|
|
|
|
final String camelCaseName, |
|
|
|
|
final Class<? extends GeneratedMessageV3> messageClass, |
|
|
|
|
final Class<? extends Builder> builderClass, |
|
|
|
|
final Class<? extends Builder<?>> builderClass, |
|
|
|
|
final String containingOneofCamelCaseName, |
|
|
|
|
boolean isOneofField, |
|
|
|
|
boolean hasHasMethod) { |
|
|
|
@ -2411,7 +2402,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
final FieldDescriptor descriptor, |
|
|
|
|
final String camelCaseName, |
|
|
|
|
final Class<? extends GeneratedMessageV3> messageClass, |
|
|
|
|
final Class<? extends Builder> builderClass, |
|
|
|
|
final Class<? extends Builder<?>> builderClass, |
|
|
|
|
final String containingOneofCamelCaseName) { |
|
|
|
|
isOneofField = |
|
|
|
|
descriptor.getContainingOneof() != null |
|
|
|
@ -2453,7 +2444,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object get(GeneratedMessageV3.Builder builder) { |
|
|
|
|
public Object get(GeneratedMessageV3.Builder<?> builder) { |
|
|
|
|
return invoker.get(builder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2463,12 +2454,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getRaw(GeneratedMessageV3.Builder builder) { |
|
|
|
|
return get(builder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void set(final Builder builder, final Object value) { |
|
|
|
|
public void set(final Builder<?> builder, final Object value) { |
|
|
|
|
invoker.set(builder, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2478,29 +2464,17 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getRepeatedRaw(final GeneratedMessageV3 message, final int index) { |
|
|
|
|
throw new UnsupportedOperationException( |
|
|
|
|
"getRepeatedFieldRaw() called on a singular field."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getRepeated(GeneratedMessageV3.Builder builder, int index) { |
|
|
|
|
public Object getRepeated(GeneratedMessageV3.Builder<?> builder, int index) { |
|
|
|
|
throw new UnsupportedOperationException("getRepeatedField() called on a singular field."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getRepeatedRaw(GeneratedMessageV3.Builder builder, int index) { |
|
|
|
|
throw new UnsupportedOperationException( |
|
|
|
|
"getRepeatedFieldRaw() called on a singular field."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setRepeated(final Builder builder, final int index, final Object value) { |
|
|
|
|
public void setRepeated(final Builder<?> builder, final int index, final Object value) { |
|
|
|
|
throw new UnsupportedOperationException("setRepeatedField() called on a singular field."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void addRepeated(final Builder builder, final Object value) { |
|
|
|
|
public void addRepeated(final Builder<?> builder, final Object value) { |
|
|
|
|
throw new UnsupportedOperationException("addRepeatedField() called on a singular field."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2516,7 +2490,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean has(GeneratedMessageV3.Builder builder) { |
|
|
|
|
public boolean has(GeneratedMessageV3.Builder<?> builder) { |
|
|
|
|
if (!hasHasMethod) { |
|
|
|
|
if (isOneofField) { |
|
|
|
|
return invoker.getOneofFieldNumber(builder) == field.getNumber(); |
|
|
|
@ -2533,13 +2507,13 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int getRepeatedCount(GeneratedMessageV3.Builder builder) { |
|
|
|
|
public int getRepeatedCount(GeneratedMessageV3.Builder<?> builder) { |
|
|
|
|
throw new UnsupportedOperationException( |
|
|
|
|
"getRepeatedFieldSize() called on a singular field."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void clear(final Builder builder) { |
|
|
|
|
public void clear(final Builder<?> builder) { |
|
|
|
|
invoker.clear(builder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2598,7 +2572,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
final FieldDescriptor descriptor, |
|
|
|
|
final String camelCaseName, |
|
|
|
|
final Class<? extends GeneratedMessageV3> messageClass, |
|
|
|
|
final Class<? extends Builder> builderClass) { |
|
|
|
|
final Class<? extends Builder<?>> builderClass) { |
|
|
|
|
getMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "List"); |
|
|
|
|
getMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "List"); |
|
|
|
|
getRepeatedMethod = getMethodOrDie(messageClass, "get" + camelCaseName, Integer.TYPE); |
|
|
|
@ -2663,14 +2637,14 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected final Class type; |
|
|
|
|
protected final Class<?> type; |
|
|
|
|
protected final MethodInvoker invoker; |
|
|
|
|
|
|
|
|
|
RepeatedFieldAccessor( |
|
|
|
|
final FieldDescriptor descriptor, |
|
|
|
|
final String camelCaseName, |
|
|
|
|
final Class<? extends GeneratedMessageV3> messageClass, |
|
|
|
|
final Class<? extends Builder> builderClass) { |
|
|
|
|
final Class<? extends Builder<?>> builderClass) { |
|
|
|
|
ReflectionInvoker reflectionInvoker = |
|
|
|
|
new ReflectionInvoker(descriptor, camelCaseName, messageClass, builderClass); |
|
|
|
|
type = reflectionInvoker.getRepeatedMethod.getReturnType(); |
|
|
|
@ -2687,7 +2661,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object get(GeneratedMessageV3.Builder builder) { |
|
|
|
|
public Object get(GeneratedMessageV3.Builder<?> builder) { |
|
|
|
|
return invoker.get(builder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2697,12 +2671,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getRaw(GeneratedMessageV3.Builder builder) { |
|
|
|
|
return get(builder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void set(final Builder builder, final Object value) { |
|
|
|
|
public void set(final Builder<?> builder, final Object value) { |
|
|
|
|
// Add all the elements individually. This serves two purposes:
|
|
|
|
|
// 1) Verifies that each element has the correct type.
|
|
|
|
|
// 2) Insures that the caller cannot modify the list later on and
|
|
|
|
@ -2719,27 +2688,17 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getRepeated(GeneratedMessageV3.Builder builder, int index) { |
|
|
|
|
public Object getRepeated(GeneratedMessageV3.Builder<?> builder, int index) { |
|
|
|
|
return invoker.getRepeated(builder, index); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getRepeatedRaw(GeneratedMessageV3 message, int index) { |
|
|
|
|
return getRepeated(message, index); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getRepeatedRaw(GeneratedMessageV3.Builder builder, int index) { |
|
|
|
|
return getRepeated(builder, index); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setRepeated(final Builder builder, final int index, final Object value) { |
|
|
|
|
public void setRepeated(final Builder<?> builder, final int index, final Object value) { |
|
|
|
|
invoker.setRepeated(builder, index, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void addRepeated(final Builder builder, final Object value) { |
|
|
|
|
public void addRepeated(final Builder<?> builder, final Object value) { |
|
|
|
|
invoker.addRepeated(builder, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2749,7 +2708,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean has(GeneratedMessageV3.Builder builder) { |
|
|
|
|
public boolean has(GeneratedMessageV3.Builder<?> builder) { |
|
|
|
|
throw new UnsupportedOperationException("hasField() called on a repeated field."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2759,12 +2718,12 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int getRepeatedCount(GeneratedMessageV3.Builder builder) { |
|
|
|
|
public int getRepeatedCount(GeneratedMessageV3.Builder<?> builder) { |
|
|
|
|
return invoker.getRepeatedCount(builder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void clear(final Builder builder) { |
|
|
|
|
public void clear(final Builder<?> builder) { |
|
|
|
|
invoker.clear(builder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2803,11 +2762,11 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
return (MapField<?, ?>) message.internalGetMapField(field.getNumber()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private MapField<?, ?> getMapField(GeneratedMessageV3.Builder builder) { |
|
|
|
|
private MapField<?, ?> getMapField(GeneratedMessageV3.Builder<?> builder) { |
|
|
|
|
return (MapField<?, ?>) builder.internalGetMapField(field.getNumber()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private MapField<?, ?> getMutableMapField(GeneratedMessageV3.Builder builder) { |
|
|
|
|
private MapField<?, ?> getMutableMapField(GeneratedMessageV3.Builder<?> builder) { |
|
|
|
|
return (MapField<?, ?>) builder.internalGetMutableMapField(field.getNumber()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2826,9 +2785,8 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
public Object get(GeneratedMessageV3 message) { |
|
|
|
|
List result = new ArrayList<>(); |
|
|
|
|
List<Object> result = new ArrayList<>(); |
|
|
|
|
for (int i = 0; i < getRepeatedCount(message); i++) { |
|
|
|
|
result.add(getRepeated(message, i)); |
|
|
|
|
} |
|
|
|
@ -2836,9 +2794,8 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
public Object get(Builder builder) { |
|
|
|
|
List result = new ArrayList<>(); |
|
|
|
|
public Object get(Builder<?> builder) { |
|
|
|
|
List<Object> result = new ArrayList<>(); |
|
|
|
|
for (int i = 0; i < getRepeatedCount(builder); i++) { |
|
|
|
|
result.add(getRepeated(builder, i)); |
|
|
|
|
} |
|
|
|
@ -2851,14 +2808,9 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getRaw(GeneratedMessageV3.Builder builder) { |
|
|
|
|
return get(builder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void set(Builder builder, Object value) { |
|
|
|
|
public void set(Builder<?> builder, Object value) { |
|
|
|
|
clear(builder); |
|
|
|
|
for (Object entry : (List) value) { |
|
|
|
|
for (Object entry : (List<?>) value) { |
|
|
|
|
addRepeated(builder, entry); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -2869,27 +2821,17 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getRepeated(Builder builder, int index) { |
|
|
|
|
public Object getRepeated(Builder<?> builder, int index) { |
|
|
|
|
return getMapField(builder).getList().get(index); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getRepeatedRaw(GeneratedMessageV3 message, int index) { |
|
|
|
|
return getRepeated(message, index); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getRepeatedRaw(Builder builder, int index) { |
|
|
|
|
return getRepeated(builder, index); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setRepeated(Builder builder, int index, Object value) { |
|
|
|
|
public void setRepeated(Builder<?> builder, int index, Object value) { |
|
|
|
|
getMutableMapField(builder).getMutableList().set(index, coerceType((Message) value)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void addRepeated(Builder builder, Object value) { |
|
|
|
|
public void addRepeated(Builder<?> builder, Object value) { |
|
|
|
|
getMutableMapField(builder).getMutableList().add(coerceType((Message) value)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2899,7 +2841,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean has(Builder builder) { |
|
|
|
|
public boolean has(Builder<?> builder) { |
|
|
|
|
throw new UnsupportedOperationException("hasField() is not supported for repeated fields."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2909,12 +2851,12 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int getRepeatedCount(Builder builder) { |
|
|
|
|
public int getRepeatedCount(Builder<?> builder) { |
|
|
|
|
return getMapField(builder).getList().size(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void clear(Builder builder) { |
|
|
|
|
public void clear(Builder<?> builder) { |
|
|
|
|
getMutableMapField(builder).getMutableList().clear(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2941,7 +2883,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
final FieldDescriptor descriptor, |
|
|
|
|
final String camelCaseName, |
|
|
|
|
final Class<? extends GeneratedMessageV3> messageClass, |
|
|
|
|
final Class<? extends Builder> builderClass, |
|
|
|
|
final Class<? extends Builder<?>> builderClass, |
|
|
|
|
final String containingOneofCamelCaseName) { |
|
|
|
|
super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); |
|
|
|
|
|
|
|
|
@ -2978,7 +2920,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object get(final GeneratedMessageV3.Builder builder) { |
|
|
|
|
public Object get(final GeneratedMessageV3.Builder<?> builder) { |
|
|
|
|
if (supportUnknownEnumValue) { |
|
|
|
|
int value = (Integer) invokeOrDie(getValueMethodBuilder, builder); |
|
|
|
|
return enumDescriptor.findValueByNumberCreatingIfUnknown(value); |
|
|
|
@ -2987,7 +2929,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void set(final Builder builder, final Object value) { |
|
|
|
|
public void set(final Builder<?> builder, final Object value) { |
|
|
|
|
if (supportUnknownEnumValue) { |
|
|
|
|
// TODO(b/230609037): remove the unused variable
|
|
|
|
|
Object unused = |
|
|
|
@ -3003,7 +2945,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
final FieldDescriptor descriptor, |
|
|
|
|
final String camelCaseName, |
|
|
|
|
final Class<? extends GeneratedMessageV3> messageClass, |
|
|
|
|
final Class<? extends Builder> builderClass) { |
|
|
|
|
final Class<? extends Builder<?>> builderClass) { |
|
|
|
|
super(descriptor, camelCaseName, messageClass, builderClass); |
|
|
|
|
|
|
|
|
|
enumDescriptor = descriptor.getEnumType(); |
|
|
|
@ -3047,7 +2989,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object get(final GeneratedMessageV3.Builder builder) { |
|
|
|
|
public Object get(final GeneratedMessageV3.Builder<?> builder) { |
|
|
|
|
final List<Object> newList = new ArrayList<>(); |
|
|
|
|
final int size = getRepeatedCount(builder); |
|
|
|
|
for (int i = 0; i < size; i++) { |
|
|
|
@ -3066,7 +3008,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object getRepeated(final GeneratedMessageV3.Builder builder, final int index) { |
|
|
|
|
public Object getRepeated(final GeneratedMessageV3.Builder<?> builder, final int index) { |
|
|
|
|
if (supportUnknownEnumValue) { |
|
|
|
|
int value = (Integer) invokeOrDie(getRepeatedValueMethodBuilder, builder, index); |
|
|
|
|
return enumDescriptor.findValueByNumberCreatingIfUnknown(value); |
|
|
|
@ -3075,7 +3017,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setRepeated(final Builder builder, final int index, final Object value) { |
|
|
|
|
public void setRepeated(final Builder<?> builder, final int index, final Object value) { |
|
|
|
|
if (supportUnknownEnumValue) { |
|
|
|
|
// TODO(b/230609037): remove the unused variable
|
|
|
|
|
Object unused = |
|
|
|
@ -3090,7 +3032,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void addRepeated(final Builder builder, final Object value) { |
|
|
|
|
public void addRepeated(final Builder<?> builder, final Object value) { |
|
|
|
|
if (supportUnknownEnumValue) { |
|
|
|
|
// TODO(b/230609037): remove the unused variable
|
|
|
|
|
Object unused = |
|
|
|
@ -3119,7 +3061,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
final FieldDescriptor descriptor, |
|
|
|
|
final String camelCaseName, |
|
|
|
|
final Class<? extends GeneratedMessageV3> messageClass, |
|
|
|
|
final Class<? extends Builder> builderClass, |
|
|
|
|
final Class<? extends Builder<?>> builderClass, |
|
|
|
|
final String containingOneofCamelCaseName) { |
|
|
|
|
super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); |
|
|
|
|
getBytesMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Bytes"); |
|
|
|
@ -3136,7 +3078,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void set(GeneratedMessageV3.Builder builder, Object value) { |
|
|
|
|
public void set(GeneratedMessageV3.Builder<?> builder, Object value) { |
|
|
|
|
if (value instanceof ByteString) { |
|
|
|
|
// TODO(b/230609037): remove the unused variable
|
|
|
|
|
Object unused = invokeOrDie(setBytesMethodBuilder, builder, value); |
|
|
|
@ -3153,7 +3095,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
final FieldDescriptor descriptor, |
|
|
|
|
final String camelCaseName, |
|
|
|
|
final Class<? extends GeneratedMessageV3> messageClass, |
|
|
|
|
final Class<? extends Builder> builderClass, |
|
|
|
|
final Class<? extends Builder<?>> builderClass, |
|
|
|
|
final String containingOneofCamelCaseName) { |
|
|
|
|
super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); |
|
|
|
|
|
|
|
|
@ -3179,7 +3121,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void set(final Builder builder, final Object value) { |
|
|
|
|
public void set(final Builder<?> builder, final Object value) { |
|
|
|
|
super.set(builder, coerceType(value)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -3199,7 +3141,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
final FieldDescriptor descriptor, |
|
|
|
|
final String camelCaseName, |
|
|
|
|
final Class<? extends GeneratedMessageV3> messageClass, |
|
|
|
|
final Class<? extends Builder> builderClass) { |
|
|
|
|
final Class<? extends Builder<?>> builderClass) { |
|
|
|
|
super(descriptor, camelCaseName, messageClass, builderClass); |
|
|
|
|
|
|
|
|
|
newBuilderMethod = getMethodOrDie(type, "newBuilder"); |
|
|
|
@ -3225,12 +3167,12 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setRepeated(final Builder builder, final int index, final Object value) { |
|
|
|
|
public void setRepeated(final Builder<?> builder, final int index, final Object value) { |
|
|
|
|
super.setRepeated(builder, index, coerceType(value)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void addRepeated(final Builder builder, final Object value) { |
|
|
|
|
public void addRepeated(final Builder<?> builder, final Object value) { |
|
|
|
|
super.addRepeated(builder, coerceType(value)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|