code: private static String getString(Object value) {
  
          // The logic here is slightly icky, as getValue may or may not exist,
          // and must be called reflectively if it does exist
  
          if (!(value instanceof Enum)) {
              return value.toString();
          }
  
          Method method = null;
          try {
              method = value.getClass().getMethod("getValue");
          } catch (NoSuchMethodException e) {
          } catch (SecurityException e) {
          }
          if (method != null && method.getReturnType() != String.class) {
              method = null;
          }
  
          if (method == null) {
              // There was no appropriate getValue method, so rely on toString
              return value.toString();
          }
  
          // An error at this point is unrecoverable, something is really wrong
          String answer = null;
          try {
              answer = (String) method.invoke(value);
          } catch (IllegalAccessException e) {
              throw new RuntimeException("The enum " + value.getClass().getName()
                                         + " was expected to have a public getValue method", e);
          } catch (IllegalArgumentException e) {
              throw new RuntimeException("The enum " + value.getClass().getName()
                                         + " was expected to have a public getValue method with no arguments", e);
          } catch (InvocationTargetException e) {
              throw new RuntimeException("The enum " + value.getClass().getName()
                                         + " getValue method threw an unexpectd exception", e);
          }
  
          return answer;
  
      }
docs: From the 'value' object, find the field name that will be filtered on, which is a effectively a key into
  a JSON object. This will generally be the result of calling toString on the object, but
  for enums, there maybe a getValue method which be used instead.
  
  @param value
  @return