package io.burt.jmespath.function;

import java.util.List;
import java.util.Arrays;

import io.burt.jmespath.Adapter;
import io.burt.jmespath.JmesPathType;

public class ToArrayFunction extends BaseFunction {
  public ToArrayFunction() {
    super(ArgumentConstraints.anyValue());
  }

  @Override
  protected <T> T callFunction(Adapter<T> runtime, List<FunctionArgument<T>> arguments) {
    T subject = arguments.get(0).value();
    if (runtime.typeOf(subject) == JmesPathType.ARRAY) {
      return subject;
    } else {
      return runtime.createArray(Arrays.asList(subject));
    }
  }
}

@@ -29,16 +29,46 @@
 ction;%0A%0A
+import java.util.Collections;%0A
 import j
@@ -582,17 +582,29 @@
 ray(
-Arrays.as
+Collections.singleton
 List

Use the right kind of list creating method to show the correct intent