diff --git a/java/core/src/main/java/com/google/protobuf/Message.java b/java/core/src/main/java/com/google/protobuf/Message.java index 5b02c464ae..7fc8cd4a58 100644 --- a/java/core/src/main/java/com/google/protobuf/Message.java +++ b/java/core/src/main/java/com/google/protobuf/Message.java @@ -102,40 +102,80 @@ public interface Message extends MessageLite, MessageOrBuilder { @CanIgnoreReturnValue Builder mergeFrom(Message other); + @Override + @CanIgnoreReturnValue + Builder mergeFrom(CodedInputStream input) throws IOException; + + @Override + @CanIgnoreReturnValue + Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) + throws IOException; + + // --------------------------------------------------------------- + // Convenience methods. + // (From MessageLite.Builder, re-declared here only for return type // covariance.) @Override - Message build(); + @CanIgnoreReturnValue + Builder mergeFrom(ByteString data) throws InvalidProtocolBufferException; @Override - Message buildPartial(); + @CanIgnoreReturnValue + Builder mergeFrom(ByteString data, ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException; @Override - Builder clone(); + @CanIgnoreReturnValue + Builder mergeFrom(byte[] data) throws InvalidProtocolBufferException; @Override @CanIgnoreReturnValue - Builder mergeFrom(CodedInputStream input) throws IOException; + Builder mergeFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException; @Override @CanIgnoreReturnValue - Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) + Builder mergeFrom(byte[] data, ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException; + + @Override + @CanIgnoreReturnValue + Builder mergeFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException; + + @Override + @CanIgnoreReturnValue + Builder mergeFrom(InputStream input) throws IOException; + + @Override + @CanIgnoreReturnValue + Builder mergeFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws IOException; + // (From MessageLite.Builder, re-declared here only for return type + // covariance.) + @Override + Message build(); + + @Override + Message buildPartial(); + + @Override + Builder clone(); + /** Get the message's type's descriptor. See {@link Message#getDescriptorForType()}. */ @Override Descriptors.Descriptor getDescriptorForType(); /** - * Create a builder for messages of the appropriate type for the given field. The - * builder is NOT nested in the current builder. However, messages built with the - * builder can then be passed to the {@link #setField(Descriptors.FieldDescriptor, Object)}, - * {@link #setRepeatedField(Descriptors.FieldDescriptor, int, Object)}, or - * {@link #addRepeatedField(Descriptors.FieldDescriptor, Object)} - * method of the current builder. + * Create a builder for messages of the appropriate type for the given field. The builder is NOT + * nested in the current builder. However, messages built with the builder can then be passed to + * the {@link #setField(Descriptors.FieldDescriptor, Object)}, {@link + * #setRepeatedField(Descriptors.FieldDescriptor, int, Object)}, or {@link + * #addRepeatedField(Descriptors.FieldDescriptor, Object)} method of the current builder. * - *

To obtain a builder nested in the current builder, use - * {@link #getFieldBuilder(Descriptors.FieldDescriptor)} instead. + *

To obtain a builder nested in the current builder, use {@link + * #getFieldBuilder(Descriptors.FieldDescriptor)} instead. */ Builder newBuilderForField(Descriptors.FieldDescriptor field); @@ -143,13 +183,12 @@ public interface Message extends MessageLite, MessageOrBuilder { * Get a nested builder instance for the given field. * *

Normally, we hold a reference to the immutable message object for the message type field. - * Some implementations (the generated message builders) can also hold a reference to - * the builder object (a nested builder) for the field. + * Some implementations (the generated message builders) can also hold a reference to the + * builder object (a nested builder) for the field. * - *

If the field is already backed up by a nested builder, the nested builder is - * returned. Otherwise, a new field builder is created and returned. The original message - * field (if one exists) is merged into the field builder, which is then nested into its - * parent builder. + *

If the field is already backed up by a nested builder, the nested builder is returned. + * Otherwise, a new field builder is created and returned. The original message field (if one + * exists) is merged into the field builder, which is then nested into its parent builder. */ Builder getFieldBuilder(Descriptors.FieldDescriptor field); @@ -157,13 +196,12 @@ public interface Message extends MessageLite, MessageOrBuilder { * Get a nested builder instance for the given repeated field instance. * *

Normally, we hold a reference to the immutable message object for the message type field. - * Some implementations (the generated message builders) can also hold a reference to - * the builder object (a nested builder) for the field. + * Some implementations (the generated message builders) can also hold a reference to the + * builder object (a nested builder) for the field. * - *

If the field is already backed up by a nested builder, the nested builder is - * returned. Otherwise, a new field builder is created and returned. The original message - * field (if one exists) is merged into the field builder, which is then nested into its - * parent builder. + *

If the field is already backed up by a nested builder, the nested builder is returned. + * Otherwise, a new field builder is created and returned. The original message field (if one + * exists) is merged into the field builder, which is then nested into its parent builder. */ Builder getRepeatedFieldBuilder(Descriptors.FieldDescriptor field, int index); @@ -221,42 +259,6 @@ public interface Message extends MessageLite, MessageOrBuilder { // (From MessageLite.Builder, re-declared here only for return type // covariance.) - @Override - @CanIgnoreReturnValue - Builder mergeFrom(ByteString data) throws InvalidProtocolBufferException; - - @Override - @CanIgnoreReturnValue - Builder mergeFrom(ByteString data, ExtensionRegistryLite extensionRegistry) - throws InvalidProtocolBufferException; - - @Override - @CanIgnoreReturnValue - Builder mergeFrom(byte[] data) throws InvalidProtocolBufferException; - - @Override - @CanIgnoreReturnValue - Builder mergeFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException; - - @Override - @CanIgnoreReturnValue - Builder mergeFrom(byte[] data, ExtensionRegistryLite extensionRegistry) - throws InvalidProtocolBufferException; - - @Override - @CanIgnoreReturnValue - Builder mergeFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry) - throws InvalidProtocolBufferException; - - @Override - @CanIgnoreReturnValue - Builder mergeFrom(InputStream input) throws IOException; - - @Override - @CanIgnoreReturnValue - Builder mergeFrom(InputStream input, ExtensionRegistryLite extensionRegistry) - throws IOException; - @Override boolean mergeDelimitedFrom(InputStream input) throws IOException;