content: /* Generated By:JJTree: Do not edit this line. ExpScalarList.java Version 7.0 */
  /* JavaCCOptions:MULTI=true,NODE_USES_PARSER=false,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=Exp,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
  package io.agrest.exp.parser;
  
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collection;
  import java.util.Collections;
  import java.util.List;
  import java.util.stream.Collectors;
  
  public
  class ExpScalarList extends ExpBaseScalar<Collection<?>> {
  
    private static final ListValueVisitor LIST_VALUE_VISITOR = new ListValueVisitor();
  
    public ExpScalarList(int id) {
      super(id);
    }
  
    public ExpScalarList(AgExpressionParser p, int id) {
      super(p, id);
    }
  
    public ExpScalarList() {
      super(AgExpressionParserTreeConstants.JJTSCALARLIST);
    }
  
    public ExpScalarList(Object[] values) {
      this(Arrays.asList(values));
    }
  
    public ExpScalarList(Collection<?> value) {
      super(AgExpressionParserTreeConstants.JJTSCALARLIST);
      setValue(value);
    }
  
    public Collection<?> getValue() {
  
      // value is either an internal collection, or child nodes
      Collection<?> value = (Collection<?>) jjtGetValue();
      if (value != null) {
        return value;
      }
  
      if (jjtGetNumChildren() == 0) {
        return Collections.emptyList();
      }
  
      List<Object> list = new ArrayList<>();
      for (int i = 0; i < jjtGetNumChildren(); ++i) {
        jjtGetChild(i).jjtAccept(LIST_VALUE_VISITOR, list);
      }
  
      return list;
    }
  
    /** Accept the visitor. **/
    public <T> T jjtAccept(AgExpressionParserVisitor<T> visitor, T data) {
  
      return
      visitor.visit(this, data);
    }
  
    @Override
    protected ExpScalarList shallowCopy() {
      return new ExpScalarList((Collection<?>) jjtGetValue());
    }
  
    @Override
    public String toString() {
      return ExpStringConverter.convert(this);
    }
  
    private static class ListValueVisitor extends AgExpressionParserDefaultVisitor<List<Object>> {
  
      @Override
      public List<Object> visit(ExpScalar node, List<Object> data) {
        data.add(node.getValue());
        return data;
      }
  
      @Override
      public List<Object> visit(ExpScalarList node, List<Object> data) {
        data.add(node.getValue());
        return data;
      }
  
      @Override
      public List<Object> visit(ExpNamedParameter node, List<Object> data) {
        data.add(node);
        return data;
      }
    }
  }
  /* JavaCC - OriginalChecksum=a0eb03d3d264fa55970f6e6f130c84e2 (do not edit this line) */
  