package io.burt.jmespath.function;

import io.burt.jmespath.Expression;

public abstract class FunctionArgument<T> {
  private static class V<U> extends FunctionArgument<U> {
    private final U value;

    public V(U value) {
      this.value = value;
    }

    public U value() { return value; }

    public boolean isValue() { return true; }
  }

  private static class E<U> extends FunctionArgument<U> {
    private final Expression<U> expression;

    public E(Expression<U> expression) {
      this.expression = expression;
    }

    public Expression<U> expression() { return expression; }

    public boolean isExpression() { return true; }
  }

  public static <U> FunctionArgument<U> of(U value) {
    return new V<U>(value);
  }

  public static <U> FunctionArgument<U> of(Expression<U> expression) {
    return new E<U>(expression);
  }

  private FunctionArgument() { }

  public Expression<T> expression() { return null; };

  public T value() { return null; }

  public boolean isExpression() { return false; }

  public boolean isValue() { return false; }
}

@@ -66,16 +66,273 @@
 ssion;%0A%0A
+/**%0A * In JMESPath most functions take regular values as arguments, but some are%0A * higher order functions and take expressions. This class exists so that%0A * argument lists can have a single type, while still contain a mix of values%0A * and expressions.%0A */%0A
 public a
@@ -902,24 +902,96 @@
 rue; %7D%0A  %7D%0A%0A
+  /**%0A   * Creates a new function argument that contains a value.%0A   */%0A
   public sta
@@ -1061,24 +1061,102 @@
 alue);%0A  %7D%0A%0A
+  /**%0A   * Creates a new function argument that contains an expression.%0A   */%0A
   public sta
@@ -1292,148 +1292,517 @@
 %0A%0A  
-public Expression%3CT%3E expression() %7B return null; %7D;%0A%0A  public T value() %7B return null; %7D%0A%0A  public boolean isExpression() %7B return false; %7D%0A
+/**%0A   * Returns the expression contained in this argument, or null if this argument%0A   * is not an expression argument.%0A   */%0A  public Expression%3CT%3E expression() %7B return null; %7D;%0A%0A  /**%0A   * Returns the value contained in this argument, or null if this argument is%0A   * not a value argument.%0A   */%0A  public T value() %7B return null; %7D%0A%0A  /** Returns true when this argument contains an expression */%0A  public boolean isExpression() %7B return false; %7D%0A%0A  /** Returns true when this argument contains a value */
 %0A  p

Add API docs to FunctionArgument