private static @Nullable Field getField(@NotNull FileTypeBean bean, Class<Object> aClass) throws NoSuchFieldException {
    if (bean.fieldName != null) {
      return aClass.getDeclaredField(bean.fieldName);
    }

    Field field = null;
    // find the only static field inside the file type class which type == aClass
    Field[] declaredFields = aClass.getDeclaredFields();
    for (Field declaredField : declaredFields) {
      if (Modifier.isStatic(declaredField.getModifiers()) && declaredField.getType() == aClass) {
        if (field == null) {
          field = declaredField;
        }
        else {
          // ambiguity: two static fields, use neither to avoid surprises
          field = null;
          break;
        }
      }
    }
    return field;
  }
private static @Nullable Field getField(@NotNull FileTypeBean bean, Class<Object> aClass)