private void getStylesFromObject()

in stetho/src/main/java/com/facebook/stetho/inspector/elements/android/ViewDescriptor.java [440:501]


  private void getStylesFromObject(
      View view,
      String name,
      Object value,
      @Nullable ViewDebug.ExportedProperty annotation,
      StyleAccumulator styles) {
    if (annotation == null || !annotation.deepExport() || value == null) {
      return;
    }

    Field[] fields = value.getClass().getFields();

    for (Field field : fields) {
      int modifiers = field.getModifiers();
      if (Modifier.isStatic(modifiers)) {
        continue;
      }

      Object propertyValue;
      try {
          field.setAccessible(true);
          propertyValue = field.get(value);
      } catch (IllegalAccessException e) {
        LogUtil.e(
            e,
            "failed to get property of name: \"" + name + "\" of object: " + String.valueOf(value));
        return;
      }

      String propertyName = field.getName();

      switch (propertyName) {
        case "bottomMargin":
          propertyName = "margin-bottom";
          break;
        case "topMargin":
          propertyName = "margin-top";
          break;
        case "leftMargin":
          propertyName = "margin-left";
          break;
        case "rightMargin":
          propertyName = "margin-right";
          break;
        default:
          String annotationPrefix = annotation.prefix();
          propertyName = convertViewPropertyNameToCSSName(
              (annotationPrefix == null) ? propertyName : (annotationPrefix + propertyName));
          break;
      }

      ViewDebug.ExportedProperty subAnnotation =
          field.getAnnotation(ViewDebug.ExportedProperty.class);

      getStyleFromValue(
          view,
          propertyName,
          propertyValue,
          subAnnotation,
          styles);
    }
  }