Top Description Inners Fields Constructors Methods
com.google.protobuf

public final Class Any

extends GeneratedMessageV3
implements AnyOrBuilder
Class Inheritance
All Implemented Interfaces
com.google.protobuf.AnyOrBuilder, com.google.protobuf.MessageOrBuilder, com.google.protobuf.MessageLiteOrBuilder

`Any` contains an arbitrary serialized protocol buffer message along with a
URL that describes the type of the serialized message.
Protobuf library provides support to pack/unpack Any values in the form
of utility functions or additional generated methods of the Any type.
Example 1: Pack and unpack a message in C++.
    Foo foo = ...;
    Any any;
    any.PackFrom(foo);
    ...
    if (any.UnpackTo(&foo)) {
      ...
    }
Example 2: Pack and unpack a message in Java.
    Foo foo = ...;
    Any any = Any.pack(foo);
    ...
    if (any.is(Foo.class)) {
      foo = any.unpack(Foo.class);
    }
 Example 3: Pack and unpack a message in Python.
    foo = Foo(...)
    any = Any()
    any.Pack(foo)
    ...
    if any.Is(Foo.DESCRIPTOR):
      any.Unpack(foo)
      ...
 Example 4: Pack and unpack a message in Go
     foo := &pb.Foo{...}
     any, err := ptypes.MarshalAny(foo)
     ...
     foo := &pb.Foo{}
     if err := ptypes.UnmarshalAny(any, foo); err != nil {
       ...
     }
The pack methods provided by protobuf library will by default use
'type.googleapis.com/full.type.name' as the type URL and the unpack
methods only use the fully qualified type name after the last '/'
in the type URL, for example "foo.bar.com/x/y.z" will yield type
name "y.z".
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 `@type`
field. Example (for message [google.protobuf.Duration][]):
    {
      "@type": "type.googleapis.com/google.protobuf.Duration",
      "value": "1.212s"
    }
Protobuf type google.protobuf.Any

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Any.Builder

`Any` contains an arbitrary serialized protocol buffer message along with a
URL that describes the type of the serialized message.

Field Summary

Modifier and TypeField and Description
private volatile Message
private static final Any
private byte
private static final Parser<Any>
private static final long
public static final int
private volatile Object
private ByteString
public static final int
Inherited from com.google.protobuf.GeneratedMessageV3:
alwaysUseFieldBuildersunknownFields

Constructor Summary

AccessConstructor and Description
private
private
Any()

private
Any(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object
object to be compared for equality with this message
obj
)

Overrides com.google.protobuf.AbstractMessage.equals.

Implements com.google.protobuf.Message.equals.

Compares the specified object with this message for equality.
public static Any
public Any
public static final Descriptors.Descriptor
public Parser<Any>
public int
getSerializedSize()

Overrides com.google.protobuf.GeneratedMessageV3.getSerializedSize.

Implements com.google.protobuf.MessageLite.getSerializedSize.

Get the number of bytes required to encode this message.
private static String
private static String
getTypeUrl(String typeUrlPrefix, Descriptors.Descriptor descriptor)

public String
getTypeUrl()

Implements com.google.protobuf.AnyOrBuilder.getTypeUrl.

A URL/resource name that uniquely identifies the type of the serialized
protocol buffer message.
public ByteString
getTypeUrlBytes()

Implements com.google.protobuf.AnyOrBuilder.getTypeUrlBytes.

A URL/resource name that uniquely identifies the type of the serialized
protocol buffer message.
public final UnknownFieldSet
public ByteString
getValue()

Implements com.google.protobuf.AnyOrBuilder.getValue.

Must be a valid serialized protocol buffer of the above specified type.
public int
hashCode()

Overrides com.google.protobuf.AbstractMessage.hashCode.

Implements com.google.protobuf.Message.hashCode.

Returns the hash code value for this message.
protected GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable()

Implements abstract com.google.protobuf.GeneratedMessageV3.internalGetFieldAccessorTable.

Get the FieldAccessorTable for this type.
public <T extends Message> boolean
is(Class<T> clazz)

public final boolean
isInitialized()

Overrides com.google.protobuf.GeneratedMessageV3.isInitialized.

Implements com.google.protobuf.MessageLiteOrBuilder.isInitialized.

Returns true if all required fields in the message and all embedded messages are set, false otherwise.
public static Any.Builder
public static Any.Builder
newBuilder(Any prototype)

public Any.Builder
newBuilderForType()

Implements com.google.protobuf.Message.newBuilderForType, com.google.protobuf.MessageLite.newBuilderForType.

Constructs a new builder for a message of the same type as this message.
protected Any.Builder
newBuilderForType(GeneratedMessageV3.BuilderParent parent)

Implements abstract com.google.protobuf.GeneratedMessageV3.newBuilderForType.

TODO(xiaofeng): remove this together with GeneratedMessageV3.BuilderParent.
public static <T extends Message> Any
pack(T message)

public static <T extends Message> Any
pack(T message, String typeUrlPrefix)

Packs a message using the given type URL prefix.

public static Any
public static Any
public static Any
public static Any
parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

public static Any
public static Any
parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public static Any
parseFrom(byte[] data)

public static Any
parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public static Any
public static Any
parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static Any
public static Any
public static Parser<Any>
public Any.Builder
toBuilder()

Implements com.google.protobuf.Message.toBuilder, com.google.protobuf.MessageLite.toBuilder.

Constructs a builder initialized with the current message.
public <T extends Message> T
unpack(Class<T> clazz)

public void
writeTo(CodedOutputStream output)

Overrides com.google.protobuf.GeneratedMessageV3.writeTo.

Implements com.google.protobuf.MessageLite.writeTo.

Serializes the message and writes it to output.
Inherited from com.google.protobuf.GeneratedMessageV3:
canUseUnsafecomputeStringSizecomputeStringSizeNoTagemptyBooleanListemptyDoubleListemptyFloatListemptyIntListemptyLongListenableAlwaysUseFieldBuildersForTestinggetAllFieldsgetAllFieldsRawgetDescriptorForTypegetFieldgetFieldRawgetOneofFieldDescriptorgetRepeatedFieldgetRepeatedFieldCounthasFieldhasOneofinternalGetMapFieldmakeExtensionsImmutablemutableCopymutableCopymutableCopymutableCopymutableCopynewBooleanListnewBuilderForTypenewDoubleListnewFloatListnewIntListnewLongListparseDelimitedWithIOExceptionparseDelimitedWithIOExceptionparseUnknownFieldparseUnknownFieldProto3parseWithIOExceptionparseWithIOExceptionparseWithIOExceptionparseWithIOExceptionserializeBooleanMapToserializeIntegerMapToserializeLongMapToserializeStringMapTowriteReplacewriteStringwriteStringNoTag