public static final class Any.Builder extends GeneratedMessage.Builder<Any.Builder> implements AnyOrBuilder
google.protobuf.Any
`Any` contains an arbitrary serialized message along with a URL that describes the type of the serialized message. The proto runtimes and/or compiler will eventually provide utilities to pack/unpack Any values (projected Q1/15). # JSON The JSON representation of an `Any` value uses the regular representation of the deserialized, embedded message, with an additional field `@type` which contains the type URL. Example: package google.profile; message Person { string first_name = 1; string last_name = 2; } { "@type": "type.googleapis.com/google.profile.Person", "firstName": <string>, "lastName": <string> } If the embedded message type is well-known and has a custom JSON representation, that representation will be embedded adding a field `value` which holds the custom JSON in addition to the the `@type` field. Example (for message [google.protobuf.Duration][google.protobuf.Duration]): { "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" }
Modifier and Type | Method and Description |
---|---|
Any |
build()
Constructs the message based on the state of the Builder.
|
Any |
buildPartial()
Like
MessageLite.Builder.build() , but does not throw an exception if the message
is missing required fields. |
Any.Builder |
clear()
Called by the initialization and clear code paths to allow subclasses to
reset any of their builtin fields back to the initial values.
|
Any.Builder |
clearTypeUrl()
optional string type_url = 1; |
Any.Builder |
clearValue()
optional bytes value = 2; |
Any |
getDefaultInstanceForType()
Get an instance of the type with no fields set.
|
static Descriptors.Descriptor |
getDescriptor() |
Descriptors.Descriptor |
getDescriptorForType()
Get the message's type's descriptor.
|
String |
getTypeUrl()
optional string type_url = 1; |
ByteString |
getTypeUrlBytes()
optional string type_url = 1; |
ByteString |
getValue()
optional bytes value = 2; |
protected GeneratedMessage.FieldAccessorTable |
internalGetFieldAccessorTable()
Get the FieldAccessorTable for this type.
|
boolean |
isInitialized()
Returns true if all required fields in the message and all embedded
messages are set, false otherwise.
|
Any.Builder |
mergeFrom(Any other) |
Any.Builder |
mergeFrom(CodedInputStream input,
ExtensionRegistryLite extensionRegistry)
Like
MessageLite.Builder.mergeFrom(CodedInputStream) , but also
parses extensions. |
Any.Builder |
mergeFrom(Message other)
Merge
other into the message being built. |
Any.Builder |
mergeUnknownFields(UnknownFieldSet unknownFields)
Merge some unknown fields into the
UnknownFieldSet for this
message. |
Any.Builder |
setTypeUrl(String value)
optional string type_url = 1; |
Any.Builder |
setTypeUrlBytes(ByteString value)
optional string type_url = 1; |
Any.Builder |
setUnknownFields(UnknownFieldSet unknownFields)
Set the
UnknownFieldSet for this message. |
Any.Builder |
setValue(ByteString value)
optional bytes value = 2; |
addRepeatedField, clearField, clearOneof, clone, getAllFields, getField, getFieldBuilder, getOneofFieldDescriptor, getParentForChildren, getRepeatedField, getRepeatedFieldBuilder, getRepeatedFieldCount, getUnknownFields, hasField, hasOneof, internalGetMapField, internalGetMutableMapField, isClean, markClean, newBuilderForField, onBuilt, onChanged, parseUnknownField, setField, setRepeatedField
findInitializationErrors, getInitializationErrorString, mergeDelimitedFrom, mergeDelimitedFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException, toString
addAll, newUninitializedMessageException
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
findInitializationErrors, getAllFields, getField, getInitializationErrorString, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, getUnknownFields, hasField, hasOneof
public static final Descriptors.Descriptor getDescriptor()
protected GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable()
GeneratedMessage.Builder
internalGetFieldAccessorTable
in class GeneratedMessage.Builder<Any.Builder>
public Any.Builder clear()
GeneratedMessage.Builder
clear
in interface Message.Builder
clear
in interface MessageLite.Builder
clear
in class GeneratedMessage.Builder<Any.Builder>
public Descriptors.Descriptor getDescriptorForType()
Message.Builder
MessageOrBuilder.getDescriptorForType()
.getDescriptorForType
in interface Message.Builder
getDescriptorForType
in interface MessageOrBuilder
getDescriptorForType
in class GeneratedMessage.Builder<Any.Builder>
public Any getDefaultInstanceForType()
MessageLiteOrBuilder
getDefaultInstance()
method of generated message classes in that
this method is an abstract method of the MessageLite
interface
whereas getDefaultInstance()
is a static method of a specific
class. They return the same thing.getDefaultInstanceForType
in interface MessageLiteOrBuilder
getDefaultInstanceForType
in interface MessageOrBuilder
public Any build()
MessageLite.Builder
build
in interface Message.Builder
build
in interface MessageLite.Builder
public Any buildPartial()
MessageLite.Builder
MessageLite.Builder.build()
, but does not throw an exception if the message
is missing required fields. Instead, a partial message is returned.
Subsequent changes to the Builder will not affect the returned message.buildPartial
in interface Message.Builder
buildPartial
in interface MessageLite.Builder
public Any.Builder mergeFrom(Message other)
Message.Builder
other
into the message being built. other
must
have the exact same type as this
(i.e.
getDescriptorForType() == other.getDescriptorForType()
).
Merging occurs as follows. For each field:other
,
then other
's value overwrites the value in this message.other
,
it is merged into the corresponding sub-message of this message
using the same merging rules.other
are concatenated
with the elements in this message.
This is equivalent to the Message::MergeFrom
method in C++.mergeFrom
in interface Message.Builder
mergeFrom
in class AbstractMessage.Builder<Any.Builder>
public Any.Builder mergeFrom(Any other)
public final boolean isInitialized()
MessageLiteOrBuilder
isInitialized
in interface MessageLiteOrBuilder
isInitialized
in class GeneratedMessage.Builder<Any.Builder>
public Any.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws IOException
MessageLite.Builder
MessageLite.Builder.mergeFrom(CodedInputStream)
, but also
parses extensions. The extensions that you want to be able to parse
must be registered in extensionRegistry
. Extensions not in
the registry will be treated as unknown fields.mergeFrom
in interface Message.Builder
mergeFrom
in interface MessageLite.Builder
mergeFrom
in class AbstractMessage.Builder<Any.Builder>
IOException
public String getTypeUrl()
optional string type_url = 1;
A URL/resource name whose content describes the type of the serialized message. For URLs which use the schema `http`, `https`, or no schema, the following restrictions and interpretations apply: * If no schema is provided, `https` is assumed. * The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). * An HTTP GET on the URL must yield a [google.protobuf.Type][google.protobuf.Type] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Schemas other than `http`, `https` (or the empty schema) might be used with implementation specific semantics. Types originating from the `google.*` package namespace should use `type.googleapis.com/full.type.name` (without schema and path). A type service will eventually become available which serves those URLs (projected Q2/15).
getTypeUrl
in interface AnyOrBuilder
public ByteString getTypeUrlBytes()
optional string type_url = 1;
A URL/resource name whose content describes the type of the serialized message. For URLs which use the schema `http`, `https`, or no schema, the following restrictions and interpretations apply: * If no schema is provided, `https` is assumed. * The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). * An HTTP GET on the URL must yield a [google.protobuf.Type][google.protobuf.Type] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Schemas other than `http`, `https` (or the empty schema) might be used with implementation specific semantics. Types originating from the `google.*` package namespace should use `type.googleapis.com/full.type.name` (without schema and path). A type service will eventually become available which serves those URLs (projected Q2/15).
getTypeUrlBytes
in interface AnyOrBuilder
public Any.Builder setTypeUrl(String value)
optional string type_url = 1;
A URL/resource name whose content describes the type of the serialized message. For URLs which use the schema `http`, `https`, or no schema, the following restrictions and interpretations apply: * If no schema is provided, `https` is assumed. * The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). * An HTTP GET on the URL must yield a [google.protobuf.Type][google.protobuf.Type] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Schemas other than `http`, `https` (or the empty schema) might be used with implementation specific semantics. Types originating from the `google.*` package namespace should use `type.googleapis.com/full.type.name` (without schema and path). A type service will eventually become available which serves those URLs (projected Q2/15).
public Any.Builder clearTypeUrl()
optional string type_url = 1;
A URL/resource name whose content describes the type of the serialized message. For URLs which use the schema `http`, `https`, or no schema, the following restrictions and interpretations apply: * If no schema is provided, `https` is assumed. * The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). * An HTTP GET on the URL must yield a [google.protobuf.Type][google.protobuf.Type] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Schemas other than `http`, `https` (or the empty schema) might be used with implementation specific semantics. Types originating from the `google.*` package namespace should use `type.googleapis.com/full.type.name` (without schema and path). A type service will eventually become available which serves those URLs (projected Q2/15).
public Any.Builder setTypeUrlBytes(ByteString value)
optional string type_url = 1;
A URL/resource name whose content describes the type of the serialized message. For URLs which use the schema `http`, `https`, or no schema, the following restrictions and interpretations apply: * If no schema is provided, `https` is assumed. * The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). * An HTTP GET on the URL must yield a [google.protobuf.Type][google.protobuf.Type] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Schemas other than `http`, `https` (or the empty schema) might be used with implementation specific semantics. Types originating from the `google.*` package namespace should use `type.googleapis.com/full.type.name` (without schema and path). A type service will eventually become available which serves those URLs (projected Q2/15).
public ByteString getValue()
optional bytes value = 2;
Must be valid serialized data of the above specified type.
getValue
in interface AnyOrBuilder
public Any.Builder setValue(ByteString value)
optional bytes value = 2;
Must be valid serialized data of the above specified type.
public Any.Builder clearValue()
optional bytes value = 2;
Must be valid serialized data of the above specified type.
public final Any.Builder setUnknownFields(UnknownFieldSet unknownFields)
Message.Builder
UnknownFieldSet
for this message.setUnknownFields
in interface Message.Builder
setUnknownFields
in class GeneratedMessage.Builder<Any.Builder>
public final Any.Builder mergeUnknownFields(UnknownFieldSet unknownFields)
Message.Builder
UnknownFieldSet
for this
message.mergeUnknownFields
in interface Message.Builder
mergeUnknownFields
in class GeneratedMessage.Builder<Any.Builder>
Copyright © 2008–2015 Google. All rights reserved.