com.google.protobuf.Any Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protobuf-lite Show documentation
Show all versions of protobuf-lite Show documentation
A trimmed-down version of the Protocol Buffers library.
The newest version!
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/any.proto
package com.google.protobuf;
/**
*
* `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)
* ...
* 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 {@code google.protobuf.Any}
*/
public final class Any extends
com.google.protobuf.GeneratedMessageLite<
Any, Any.Builder> implements
// @@protoc_insertion_point(message_implements:google.protobuf.Any)
AnyOrBuilder {
private Any() {
typeUrl_ = "";
value_ = com.google.protobuf.ByteString.EMPTY;
}
public static final int TYPE_URL_FIELD_NUMBER = 1;
private java.lang.String typeUrl_;
/**
*
* A URL/resource name whose content describes the type of the
* serialized protocol buffer message.
* For URLs which use the scheme `http`, `https`, or no scheme, the
* following restrictions and interpretations apply:
* * If no scheme 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`).
* The name should be in a canonical form (e.g., leading "." is
* not accepted).
* * An HTTP GET on the URL must yield a [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.)
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
*
*
* optional string type_url = 1;
*/
public java.lang.String getTypeUrl() {
return typeUrl_;
}
/**
*
* A URL/resource name whose content describes the type of the
* serialized protocol buffer message.
* For URLs which use the scheme `http`, `https`, or no scheme, the
* following restrictions and interpretations apply:
* * If no scheme 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`).
* The name should be in a canonical form (e.g., leading "." is
* not accepted).
* * An HTTP GET on the URL must yield a [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.)
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
*
*
* optional string type_url = 1;
*/
public com.google.protobuf.ByteString
getTypeUrlBytes() {
return com.google.protobuf.ByteString.copyFromUtf8(typeUrl_);
}
/**
*
* A URL/resource name whose content describes the type of the
* serialized protocol buffer message.
* For URLs which use the scheme `http`, `https`, or no scheme, the
* following restrictions and interpretations apply:
* * If no scheme 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`).
* The name should be in a canonical form (e.g., leading "." is
* not accepted).
* * An HTTP GET on the URL must yield a [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.)
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
*
*
* optional string type_url = 1;
*/
private void setTypeUrl(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
typeUrl_ = value;
}
/**
*
* A URL/resource name whose content describes the type of the
* serialized protocol buffer message.
* For URLs which use the scheme `http`, `https`, or no scheme, the
* following restrictions and interpretations apply:
* * If no scheme 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`).
* The name should be in a canonical form (e.g., leading "." is
* not accepted).
* * An HTTP GET on the URL must yield a [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.)
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
*
*
* optional string type_url = 1;
*/
private void clearTypeUrl() {
typeUrl_ = getDefaultInstance().getTypeUrl();
}
/**
*
* A URL/resource name whose content describes the type of the
* serialized protocol buffer message.
* For URLs which use the scheme `http`, `https`, or no scheme, the
* following restrictions and interpretations apply:
* * If no scheme 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`).
* The name should be in a canonical form (e.g., leading "." is
* not accepted).
* * An HTTP GET on the URL must yield a [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.)
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
*
*
* optional string type_url = 1;
*/
private void setTypeUrlBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
typeUrl_ = value.toStringUtf8();
}
public static final int VALUE_FIELD_NUMBER = 2;
private com.google.protobuf.ByteString value_;
/**
*
* Must be a valid serialized protocol buffer of the above specified type.
*
*
* optional bytes value = 2;
*/
public com.google.protobuf.ByteString getValue() {
return value_;
}
/**
*
* Must be a valid serialized protocol buffer of the above specified type.
*
*
* optional bytes value = 2;
*/
private void setValue(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
value_ = value;
}
/**
*
* Must be a valid serialized protocol buffer of the above specified type.
*
*
* optional bytes value = 2;
*/
private void clearValue() {
value_ = getDefaultInstance().getValue();
}
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!typeUrl_.isEmpty()) {
output.writeString(1, getTypeUrl());
}
if (!value_.isEmpty()) {
output.writeBytes(2, value_);
}
}
public int getSerializedSize() {
int size = memoizedSerializedSize;
if (size != -1) return size;
size = 0;
if (!typeUrl_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeStringSize(1, getTypeUrl());
}
if (!value_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(2, value_);
}
memoizedSerializedSize = size;
return size;
}
public static com.google.protobuf.Any parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return com.google.protobuf.GeneratedMessageLite.parseFrom(
DEFAULT_INSTANCE, data);
}
public static com.google.protobuf.Any parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return com.google.protobuf.GeneratedMessageLite.parseFrom(
DEFAULT_INSTANCE, data, extensionRegistry);
}
public static com.google.protobuf.Any parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return com.google.protobuf.GeneratedMessageLite.parseFrom(
DEFAULT_INSTANCE, data);
}
public static com.google.protobuf.Any parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return com.google.protobuf.GeneratedMessageLite.parseFrom(
DEFAULT_INSTANCE, data, extensionRegistry);
}
public static com.google.protobuf.Any parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageLite.parseFrom(
DEFAULT_INSTANCE, input);
}
public static com.google.protobuf.Any parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageLite.parseFrom(
DEFAULT_INSTANCE, input, extensionRegistry);
}
public static com.google.protobuf.Any parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return parseDelimitedFrom(DEFAULT_INSTANCE, input);
}
public static com.google.protobuf.Any parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry);
}
public static com.google.protobuf.Any parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageLite.parseFrom(
DEFAULT_INSTANCE, input);
}
public static com.google.protobuf.Any parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageLite.parseFrom(
DEFAULT_INSTANCE, input, extensionRegistry);
}
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(com.google.protobuf.Any prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
/**
*
* `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)
* ...
* 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 {@code google.protobuf.Any}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageLite.Builder<
com.google.protobuf.Any, Builder> implements
// @@protoc_insertion_point(builder_implements:google.protobuf.Any)
com.google.protobuf.AnyOrBuilder {
// Construct using com.google.protobuf.Any.newBuilder()
private Builder() {
super(DEFAULT_INSTANCE);
}
/**
*
* A URL/resource name whose content describes the type of the
* serialized protocol buffer message.
* For URLs which use the scheme `http`, `https`, or no scheme, the
* following restrictions and interpretations apply:
* * If no scheme 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`).
* The name should be in a canonical form (e.g., leading "." is
* not accepted).
* * An HTTP GET on the URL must yield a [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.)
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
*
*
* optional string type_url = 1;
*/
public java.lang.String getTypeUrl() {
return instance.getTypeUrl();
}
/**
*
* A URL/resource name whose content describes the type of the
* serialized protocol buffer message.
* For URLs which use the scheme `http`, `https`, or no scheme, the
* following restrictions and interpretations apply:
* * If no scheme 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`).
* The name should be in a canonical form (e.g., leading "." is
* not accepted).
* * An HTTP GET on the URL must yield a [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.)
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
*
*
* optional string type_url = 1;
*/
public com.google.protobuf.ByteString
getTypeUrlBytes() {
return instance.getTypeUrlBytes();
}
/**
*
* A URL/resource name whose content describes the type of the
* serialized protocol buffer message.
* For URLs which use the scheme `http`, `https`, or no scheme, the
* following restrictions and interpretations apply:
* * If no scheme 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`).
* The name should be in a canonical form (e.g., leading "." is
* not accepted).
* * An HTTP GET on the URL must yield a [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.)
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
*
*
* optional string type_url = 1;
*/
public Builder setTypeUrl(
java.lang.String value) {
copyOnWrite();
instance.setTypeUrl(value);
return this;
}
/**
*
* A URL/resource name whose content describes the type of the
* serialized protocol buffer message.
* For URLs which use the scheme `http`, `https`, or no scheme, the
* following restrictions and interpretations apply:
* * If no scheme 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`).
* The name should be in a canonical form (e.g., leading "." is
* not accepted).
* * An HTTP GET on the URL must yield a [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.)
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
*
*
* optional string type_url = 1;
*/
public Builder clearTypeUrl() {
copyOnWrite();
instance.clearTypeUrl();
return this;
}
/**
*
* A URL/resource name whose content describes the type of the
* serialized protocol buffer message.
* For URLs which use the scheme `http`, `https`, or no scheme, the
* following restrictions and interpretations apply:
* * If no scheme 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`).
* The name should be in a canonical form (e.g., leading "." is
* not accepted).
* * An HTTP GET on the URL must yield a [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.)
* Schemes other than `http`, `https` (or the empty scheme) might be
* used with implementation specific semantics.
*
*
* optional string type_url = 1;
*/
public Builder setTypeUrlBytes(
com.google.protobuf.ByteString value) {
copyOnWrite();
instance.setTypeUrlBytes(value);
return this;
}
/**
*
* Must be a valid serialized protocol buffer of the above specified type.
*
*
* optional bytes value = 2;
*/
public com.google.protobuf.ByteString getValue() {
return instance.getValue();
}
/**
*
* Must be a valid serialized protocol buffer of the above specified type.
*
*
* optional bytes value = 2;
*/
public Builder setValue(com.google.protobuf.ByteString value) {
copyOnWrite();
instance.setValue(value);
return this;
}
/**
*
* Must be a valid serialized protocol buffer of the above specified type.
*
*
* optional bytes value = 2;
*/
public Builder clearValue() {
copyOnWrite();
instance.clearValue();
return this;
}
// @@protoc_insertion_point(builder_scope:google.protobuf.Any)
}
protected final Object dynamicMethod(
com.google.protobuf.GeneratedMessageLite.MethodToInvoke method,
Object arg0, Object arg1) {
switch (method) {
case NEW_MUTABLE_INSTANCE: {
return new com.google.protobuf.Any();
}
case IS_INITIALIZED: {
return DEFAULT_INSTANCE;
}
case MAKE_IMMUTABLE: {
return null;
}
case NEW_BUILDER: {
return new Builder();
}
case VISIT: {
Visitor visitor = (Visitor) arg0;
com.google.protobuf.Any other = (com.google.protobuf.Any) arg1;
typeUrl_ = visitor.visitString(!typeUrl_.isEmpty(), typeUrl_,
!other.typeUrl_.isEmpty(), other.typeUrl_);
value_ = visitor.visitByteString(value_ != com.google.protobuf.ByteString.EMPTY, value_,
other.value_ != com.google.protobuf.ByteString.EMPTY, other.value_);
if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor
.INSTANCE) {
}
return this;
}
case MERGE_FROM_STREAM: {
com.google.protobuf.CodedInputStream input =
(com.google.protobuf.CodedInputStream) arg0;
com.google.protobuf.ExtensionRegistryLite extensionRegistry =
(com.google.protobuf.ExtensionRegistryLite) arg1;
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
default: {
if (!input.skipField(tag)) {
done = true;
}
break;
}
case 10: {
String s = input.readStringRequireUtf8();
typeUrl_ = s;
break;
}
case 18: {
value_ = input.readBytes();
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw new RuntimeException(e.setUnfinishedMessage(this));
} catch (java.io.IOException e) {
throw new RuntimeException(
new com.google.protobuf.InvalidProtocolBufferException(
e.getMessage()).setUnfinishedMessage(this));
} finally {
}
}
case GET_DEFAULT_INSTANCE: {
return DEFAULT_INSTANCE;
}
case GET_PARSER: {
if (PARSER == null) { synchronized (com.google.protobuf.Any.class) {
if (PARSER == null) {
PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE);
}
}
}
return PARSER;
}
}
throw new UnsupportedOperationException();
}
// @@protoc_insertion_point(class_scope:google.protobuf.Any)
private static final com.google.protobuf.Any DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new Any();
DEFAULT_INSTANCE.makeImmutable();
}
public static com.google.protobuf.Any getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static volatile com.google.protobuf.Parser PARSER;
public static com.google.protobuf.Parser parser() {
return DEFAULT_INSTANCE.getParserForType();
}
}