类 Any

java.lang.Object
com.baidu.bjf.remoting.protobuf.Any

public class Any extends Object
  * `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
  • 构造器详细资料

    • Any

      public Any()
  • 方法详细资料

    • getCodecClass

      public String getCodecClass()
      Gets the codec class.
      返回:
      the codec class
    • setCodecClass

      public void setCodecClass(String codecClass)
      Sets the codec class.
      参数:
      codecClass - the new codec class
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object
    • getAsClass

      protected Class<?> 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

      public static Any pack(Object o, String mappingClsName) throws IOException
      Pack the target object to Any object
      参数:
      o - the o
      mappingClsName - the mapping class name for origin protobuf
      返回:
      the any
      抛出:
      IOException - Signals that an I/O exception has occurred.
    • pack

      public static Any pack(Object o) throws IOException
      Pack the target object to Any object
      参数:
      o - the o
      返回:
      the any
      抛出:
      IOException - Signals that an I/O exception has occurred.
    • is

      public <T> boolean is(Class<T> cls)
      Checks if is.
      类型参数:
      T - the generic type
      参数:
      cls - the cls
      返回:
      true, if successful
    • unpack

      public <T> T unpack(Class<T> cls) throws IOException
      Unpack.
      类型参数:
      T - the generic type
      参数:
      cls - the cls
      返回:
      the t
      抛出:
      IOException - Signals that an I/O exception has occurred.