package io.burt.jmespath;

import java.util.List;
import java.util.Comparator;
import java.util.Map;

import io.burt.jmespath.function.ExpressionOrValue;

public interface Adapter<T> extends Comparator<T> {
  T parseString(String str);

  List<T> toList(T array);

  boolean isArray(T value);

  boolean isObject(T value);

  boolean isNumber(T value);

  boolean isTruthy(T value);

  boolean isNull(T value);

  String typeOf(T value);

  T getProperty(T value, String name);

  T createNull();

  T createArray(List<T> elements);

  T createArray(List<T> elements, boolean compact);

  T createString(String str);

  T createBoolean(boolean b);

  T createObject(Map<String, T> obj);

  T callFunction(String name, List<ExpressionOrValue<T>> arguments);
}

@@ -152,540 +152,2581 @@
 e;%0A%0A
-public interface Adapter%3CT%3E extends Comparator%3CT%3E %7B%0A  T parseString(String str);%0A%0A  List%3CT%3E toList(T array);%0A%0A  boolean isArray(T value);%0A%0A  boolean isObject(T value);%0A%0A  boolean isNumber(T value);%0A%0A  boolean isTruthy(T value);%0A%0A  boolean isNull(T value);%0A%0A  String typeOf(T value);%0A%0A  T getProperty(T value, String name);%0A%0A  T createNull();%0A%0A  T createArray(List%3CT%3E elements);%0A%0A  T createArray(List%3CT%3E elements, boolean compact);%0A%0A  T createString(String str);%0A%0A  T createBoolean(boolean b);%0A%0A  T createObject(Map%3CString, T%3E obj);%0A
+/**%0A * An adapter helps the JMESPath parser and interpreter work with a JSON-like%0A * structure without having to know how it works. Implement this interface%0A * to make it possible to query any JSON-like structure with JMESPath.%0A */%0Apublic interface Adapter%3CT%3E extends Comparator%3CT%3E %7B%0A  /**%0A   * Parse a JSON string to a value.%0A   */%0A  T parseString(String str);%0A%0A  /**%0A   * Converts the argument to a List%3CT%3E.%0A   *%0A   * The argument is either an array or an object. In the latter case the%0A   * result is the object's values.%0A   */%0A  List%3CT%3E toList(T array);%0A%0A  /**%0A   * Returns true when the argument is an array.%0A   */%0A  boolean isArray(T value);%0A%0A  /**%0A   * Returns true when the argument is an object.%0A   */%0A  boolean isObject(T value);%0A%0A  /**%0A   * Returns true when the argument is a number.%0A   */%0A  boolean isNumber(T value);%0A%0A  /**%0A   * Returns true when the argument is truthy.%0A   *%0A   * All values are truthy, except the following, as per the JMESPath%0A   * specification: false, null, empty lists, empty objects, empty strings.%0A   */%0A  boolean isTruthy(T value);%0A%0A  /**%0A   * Returns true when the argument represets null.%0A   */%0A  boolean isNull(T value);%0A%0A  /**%0A   * Returns the JSON type of the argument.%0A   *%0A   * As per the JMESPath specification the types are: number, string, boolean,%0A   * array, object, null.%0A   */%0A  String typeOf(T value);%0A%0A  /**%0A   * Returns a property from an object.%0A   *%0A   * The first argument must be an object and the second argument may be%0A   * a property on that object. When the property does not exist or is null%0A   * a null value (but not Java null) is returned.%0A   */%0A  T getProperty(T value, String name);%0A%0A  /**%0A   * Returns a null value (but not Java null).%0A   */%0A  T createNull();%0A%0A  /**%0A   * Returns an array with the specified elements.%0A   */%0A  T createArray(List%3CT%3E elements);%0A%0A  /**%0A   * Returns an array with the specified elements, and optionally filters%0A   * out null values.%0A   */%0A  T createArray(List%3CT%3E elements, boolean compact);%0A%0A  /**%0A   * Returns a string value containing the specified string.%0A   */%0A  T createString(String str);%0A%0A  /**%0A   * Returns a boolean value containing the specified boolean.%0A   */%0A  T createBoolean(boolean b);%0A%0A  /**%0A   * Returns an object with the specified properties.%0A   *%0A   * Does not support creating nested objects.%0A   */%0A  T createObject(Map%3CString, T%3E obj);%0A%0A  /**%0A   * Calls a function with the specified arguments and returns the result.%0A   *%0A   * Arguments can be either JMESPath expressions or values. How the arguments%0A   * are interpreted is up to the function.%0A   */
 %0A  T

Add API docs to the Adapter interface