类 Any
java.lang.Object
com.baidu.bjf.remoting.protobuf.Any
* `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.
Foo foo = ...;
Any any = Any.pack(foo);
...
if (any.is(Foo.class)) {
foo = any.unpack(Foo.class);
}
- 从以下版本开始:
- 2.4.3
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected Class<?>Gets the as class.byte[]Gets the byte array.Gets the codec class.<T> booleanChecks if is.static AnyPack the target object toAnyobjectstatic AnyPack the target object toAnyobjectvoidsetByteArray(byte[] byteArray) Sets the byte array.voidsetCodecClass(String codecClass) Sets the codec class.toString()<T> TUnpack.
-
构造器详细资料
-
Any
public Any()
-
-
方法详细资料
-
getCodecClass
Gets the codec class.- 返回:
- the codec class
-
setCodecClass
Sets the codec class.- 参数:
codecClass- the new codec class
-
toString
-
getAsClass
Gets the as class.- 返回:
- the as class
-
getByteArray
public byte[] getByteArray()Gets the byte array.- 返回:
- the byte array
-
setByteArray
public void setByteArray(byte[] byteArray) Sets the byte array.- 参数:
byteArray- the new byte array
-
pack
Pack the target object toAnyobject- 参数:
o- the omappingClsName- the mapping class name for origin protobuf- 返回:
- the any
- 抛出:
IOException- Signals that an I/O exception has occurred.
-
pack
Pack the target object toAnyobject- 参数:
o- the o- 返回:
- the any
- 抛出:
IOException- Signals that an I/O exception has occurred.
-
is
Checks if is.- 类型参数:
T- the generic type- 参数:
cls- the cls- 返回:
- true, if successful
-
unpack
Unpack.- 类型参数:
T- the generic type- 参数:
cls- the cls- 返回:
- the t
- 抛出:
IOException- Signals that an I/O exception has occurred.
-