/*
Note that both an empty Set and an empty Map are represented by {}. The
parser will always parse {} as an empty Set and special handling is required
to convert it to an empty Map when appropriate.
335099
final public void SetData() throws ParseException {
                          /*@bgen(jjtree) SetData */
  AstSetData jjtn000 = new AstSetData(JJTSETDATA);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
    try {
      jj_consume_token(START_SET_OR_MAP);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case START_SET_OR_MAP:
      case INTEGER_LITERAL:
      case FLOATING_POINT_LITERAL:
      case STRING_LITERAL:
      case TRUE:
      case FALSE:
      case NULL:
      case LPAREN:
      case LBRACK:
      case NOT0:
      case NOT1:
      case EMPTY:
      case MINUS:
      case IDENTIFIER:
        Expression();
        label_16:
        while (true) {
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case COMMA:
            ;
            break;
          default:
            jj_la1[42] = jj_gen;
            break label_16;
          }
          jj_consume_token(COMMA);
          Expression();
        }
        break;
      default:
        jj_la1[43] = jj_gen;
        ;
      }
      jj_consume_token(RBRACE);
    } catch (Throwable jjte000) {
      if (jjtc000) {
        jjtree.clearNodeScope(jjtn000);
        jjtc000 = false;
      } else {
        jjtree.popNode();
      }
      if (jjte000 instanceof RuntimeException) {
        {if (true) throw (RuntimeException)jjte000;}
      }
      if (jjte000 instanceof ParseException) {
        {if (true) throw (ParseException)jjte000;}
      }
      {if (true) throw (Error)jjte000;}
    } finally {
      if (jjtc000) {
        jjtree.closeNodeScope(jjtn000, true);
      }
    }
  }
108282
function toDeepMap(source) {
  const map = new Map();
  const keys = Object.keys(source);

  keys.forEach((key) => {
    const val = source[key];

    if (val !== null && typeof val === 'object' && !Array.isArray(val)) {
      return map.set(key, toDeepMap(val));
    }

    if (!isValidNode(val)) {
      throw new Error(`Could not add node at key "${key}", make sure it's a valid node`, val);
    }

    return map.set(key, Number(val));
  });

  return map;
}
813013
function map(fn, list) {

   return list
            ? cons(fn(head(list)), map(fn,tail(list)))
            : emptyList
            ;
}
560386
function (str, parserOptions) {
  parserOptions = parserOptions || {};
  // Do a naive test whether this is a string or an object
  var mapFn = parserOptions.map ? str.trim().charAt(0) === '[' ? underscore.map : underscore.mapObject : identity;
  var jsonParser = JSON.parse;
  return mapFn(jsonParser(str, parserOptions.reviver, parserOptions.filename), parserOptions.map);
}
175175
public static boolean isEmptyCollectionOrMap(Object obj) {
    if (obj instanceof Collection) {
      return ((Collection) obj).isEmpty();
    }

    return (obj instanceof Map && ((Map) obj).isEmpty());
  }
379170
private Map<String, Object> parseFacet(String facet) throws Exception {
        Map<String, Object> outputMap = new HashMap<>();
        if (facet.contains(AGGREGATION_IDENTIFIER)) {
            // Validate function
            for (String function : AGGREGATION_FUNCTIONS) {
                if (facet.startsWith(function)) {
                    return null;
                }
            }
            throw new Exception("Invalid aggregation function: " + facet);
        } else if (facet.contains(RANGE_IDENTIFIER)) {
            // Deal with ranges...
            int numMatches = StringUtils.countMatches(facet, ':');
            if (numMatches > 1) {
                // Special case: facet with type "query" and with a nested "range"
                String[] split = facet.split(":");
                Map<String, Object> rangeMap = new HashMap<>();
                StringBuilder filter = new StringBuilder(split[3]);
                for (int i = 4; i < split.length; i++) {
                    filter.append(":").append(split[i]);
                }

                String[] range = split[0].replace("[", ":").replace("..", ":").replace("]", "").split(":");
                rangeMap.put("field", range[0]);
                rangeMap.put("type", "range");
                rangeMap.put("start", parseNumber(range[1]));
                rangeMap.put("end", parseNumber(range[2]));
                rangeMap.put("step", parseNumber(split[1]));

                String[] nested = split[2].split(LABEL_SEPARATOR);
                outputMap.put("field", nested[0]);
                outputMap.put("type", "query");
                outputMap.put("q", filter.toString());
                if (nested.length > 1) {
                    Map<String, Object> nestedMap = new HashMap<>();
                    nestedMap.put("field", nested[1]);
                    nestedMap.put("type", "terms");
                    Map<String, Object> auxMap1 = new HashMap<>();
                    auxMap1.put(range[0], rangeMap);
                    nestedMap.put("facet", auxMap1);

                    Map<String, Object> auxMap2 = new HashMap<>();
                    auxMap2.put(nested[1], nestedMap);
                    outputMap.put("facet", auxMap2);
                } else {
                    Map<String, Object> auxMap1 = new HashMap<>();
                    auxMap1.put(range[0], rangeMap);
                    outputMap.put("facet", auxMap1);
                }
            } else {
                String[] split = facet.replace("[", ":").replace("..", ":").replace("]", "").split(":");
                outputMap.put("field", split[0]);
                outputMap.put("start", parseNumber(split[1]));
                outputMap.put("end", parseNumber(split[2]));
                outputMap.put("step", parseNumber(split[3]));
            }
        } else {
            // Categorical...
            Matcher matcher = CATEGORICAL_PATTERN.matcher(facet);
            if (matcher.find()) {
                boolean isQuery = false;
                outputMap.put("field", matcher.group(1));
                String include = matcher.group(2);
                if (StringUtils.isNotEmpty(include)) {
                    include = include.replace("]", "").replace("[", "");
                    if (include.endsWith("*")) {
                        outputMap.put("prefix", include.substring(0, include.indexOf("*")));
                    } else {
                        isQuery = true;
                        List<String> filters = new ArrayList<>();
                        for (String value: include.split(INCLUDE_SEPARATOR)) {
                            filters.add(matcher.group(1) + ":" + value);
                        }
                        outputMap.put("q", StringUtils.join(filters, " OR "));
                    }
                }

                if (isQuery) {
                    outputMap.put("type", "query");

                    Map<String, Object> auxMap = new HashMap<>();
                    auxMap.put("field", matcher.group(1));
                    auxMap.put("type", "terms");
                    setTermLimit(matcher.group(3), auxMap);

                    Map<String, Object> tmpMap = new HashMap<>();
                    tmpMap.put(matcher.group(1), auxMap);

                    outputMap.put("facet", tmpMap);
                } else {
                    outputMap.put("type", "terms");
                    setTermLimit(matcher.group(3), outputMap);
                }
            } else {
                throw new Exception("Invalid categorical facet: " + facet);
            }
        }

        return outputMap;
    }
60575
@Override
    public void parse(InputSource is, HandlerBase hb)
        throws SAXException, IOException
    {
        if (hb != null) {
            /* Ok: let's ONLY set if there are no explicit sets... not
             * extremely clear, but JDK tries to set them always so
             * let's at least do damage control.
             */
            if (mContentHandler == null) {
                setDocumentHandler(hb);
            }
            if (mEntityResolver == null) {
                setEntityResolver(hb);
            }
            if (mErrorHandler == null) {
                setErrorHandler(hb);
            }
            if (mDTDHandler == null) {
                setDTDHandler(hb);
            }
        }
        parse(is);
    }
1113697
public static void notEmpty(Map map, String name) {
    notNull(map, name);

    if (map.isEmpty()) {
      throw new IllegalArgumentException(name + " must not be empty");
    }
  }
1034629
function parseMap(map) {
	var result = [];
	for (var i = 0, ii = map.length, cursor = -1, last; i < ii; i++) {
		var isFill = map[i] != ' ' && map[i] != '0';
		if (last != isFill) {
			last = isFill;
			cursor++;
			result.push({fill: isFill, width: 1});
		} else {
			result[cursor].width++;
		}
	}
	return result;
}
192598
function parse(r, s) {
        var p = new ParseState(s, 0, []);
        if (!(r instanceof AstRule))
            r = r.ast;
        if (!r.parser(p))
            return null;
        return p && p.nodes ? p.nodes[0] : null;
    }
719632
protected void writeMap(Map<?, ?> map, CharBuf buffer) {
        if (map.isEmpty()) {
            buffer.addChars(EMPTY_MAP_CHARS);
            return;
        }
        buffer.addChar(OPEN_BRACE);
        for (Map.Entry<?, ?> entry : map.entrySet()) {
            if (entry.getKey() == null) {
                throw new IllegalArgumentException("Maps with null keys can\'t be converted to JSON");
            }
            String key = entry.getKey().toString();
            Object value = entry.getValue();
            if (isExcludingValues(value) || isExcludingFieldsNamed(key)) {
                continue;
            }
            writeMapEntry(key, value, buffer);
            buffer.addChar(COMMA);
        }
        buffer.removeLastChar(COMMA); // dangling comma
        buffer.addChar(CLOSE_BRACE);
    }
1164650
@SuppressWarnings({ "unchecked", "rawtypes" })
	private void mapToMap(Map source, Map dest) {
		if (null != dest && null != source) {
			dest.putAll(source);
		}
	}
190549
public static <K, V> Map<K, V> notEmpty(Map<K, V> map) throws IllegalArgumentException {
		return notEmpty(map, "[Assertion failed] - this map must not be empty; it must contain at least one entry");
	}
869534
private boolean appendSet(StringBuilder builder, Object value)
    {
        boolean isPresent = false;
        if (value instanceof Collection)
        {
            Collection collection = ((Collection) value);
            isPresent = true;
            builder.append(Constants.OPEN_CURLY_BRACKET);
            for (Object o : collection)
            {
                // Allowing null values.
                appendValue(builder, o != null ? o.getClass() : null, o, false);
                builder.append(Constants.COMMA);
            }
            if (!collection.isEmpty())
            {
                builder.deleteCharAt(builder.length() - 1);
            }
            builder.append(Constants.CLOSE_CURLY_BRACKET);
        }
        else
        {
            appendValue(builder, value.getClass(), value, false);
        }
        return isPresent;
    }
969632
@SuppressWarnings("rawtypes")
	public static boolean isEmpty(Object obj) {
		if(null == obj) {
			return true;
		}
		
		if(obj instanceof CharSequence) {
			return StrUtil.isEmpty((CharSequence)obj);
		}else if(obj instanceof Map) {
			return MapUtil.isEmpty((Map)obj);
		}else if(obj instanceof Iterable) {
			return IterUtil.isEmpty((Iterable)obj);
		}else if(obj instanceof Iterator) {
			return IterUtil.isEmpty((Iterator)obj);
		}else if(ArrayUtil.isArray(obj)) {
			return ArrayUtil.isEmpty(obj);
		}
		
		return false;
	}
1281449
@SuppressWarnings("unchecked")
	protected Map<String, Object> getNestedMap(Map<String, Object> map, String key) {
		Object value = map.get(key);
		if (value == null) {
			return Collections.emptyMap();
		}
		return (Map<String, Object>) value;
	}
174092
@SuppressWarnings("unchecked") // Empty immutable collection is safe to cast.
  public static <K, V> HamtPMap<K, V> empty() {
    return (HamtPMap<K, V>) EMPTY;
  }