@SneakyThrows
  public static Map<String, Object> toMap(@NonNull Object object) {
    val result = new HashMap<String, Object>();
    val type = object.getClass();
    for (val field : type.getDeclaredFields()) {
      val modifiers = field.getModifiers();
      if (isFinal(modifiers) || isStatic(modifiers)) {
        continue;
      }
      field.setAccessible(true);

      val fieldValue = field.get(object);
      if (fieldValue == null) {
        continue;
      }

      val propertyKey =
          field.isAnnotationPresent(FormProperty.class)
              ? field.getAnnotation(FormProperty.class).value()
              : field.getName();

      result.put(propertyKey, fieldValue);
    }
    return result;
  }
An utility class to work with POJOs.

@author Artem Labazin
form/src/main/java/feign/form/util/PojoUtil.java