类 FieldUtils

java.lang.Object
com.baidu.bjf.remoting.protobuf.utils.FieldUtils

public final class FieldUtils extends Object
Field utility class.
从以下版本开始:
1.0.0
作者:
xiemalin
  • 构造器详细资料

    • FieldUtils

      public FieldUtils()
  • 方法详细资料

    • toObjectType

      public static String toObjectType(String primitiveType)
    • getField

      public static Object getField(Object t, String name)
      Get the field represented by the supplied field object on the specified target object. In accordance with Field.get(Object) semantics, the returned value is automatically wrapped if the underlying field has a primitive type.

      Thrown exceptions are handled via a call to

      参数:
      t - the target object from which to get the field
      name - the field to get
      返回:
      the field's current value
    • setField

      public static void setField(Object t, String name, Object value)
      Set the field represented by the supplied field object on the specified target object to the specified value. In accordance with Field.set(Object, Object) semantics, the new value is automatically unwrapped if the underlying field has a primitive type.

      Thrown exceptions are handled via a call to

      参数:
      t - the target object on which to set the field
      name - the field to set
      value - the value to set; may be null
    • findField

      public static Field findField(Class clazz, String name)
      Attempt to find a field on the supplied Class with the supplied name. Searches all superclasses up to Object.
      参数:
      clazz - the class to introspect
      name - the name of the field
      返回:
      the corresponding Field object, or null if not found
    • findField

      public static Field findField(Class clazz, String name, Class type)
      Attempt to find a field on the supplied Class with the supplied name and/or type. Searches all superclasses up to Object.
      参数:
      clazz - the class to introspect
      name - the name of the field (may be null if type is specified)
      type - the type of the field (may be null if name is specified)
      返回:
      the corresponding Field object, or null if not found
    • findMatchedFields

      public static List<Field> findMatchedFields(Class targetClass, Class ann)
      To find out matched Field marked as Protobuf annotation
      参数:
      targetClass - taget class
      返回:
      found Field list