<commit_before>package com.jayway.jsonpath.internal.function;

import com.jayway.jsonpath.Function;
import com.jayway.jsonpath.internal.EvaluationContext;
import com.jayway.jsonpath.internal.PathRef;
import net.minidev.json.JSONArray;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Provides the length of a JSONArray Object
 *
 * Created by mattg on 6/26/15.
 */
public class Length implements Function {

    @Override
    public Object invoke(String currentPath, PathRef parent, Object model, EvaluationContext ctx) {
        if (model instanceof JSONArray) {
            JSONArray array = (JSONArray)model;
            return Integer.valueOf(array.size());
        }
        else if (model instanceof Map) {
            return Integer.valueOf(((Map) model).size());
        }
        return null;
    }
}<commit_msg>changed JSONArray -> interface Collection to catch all use-cases<commit_after>package com.jayway.jsonpath.internal.function;

import com.jayway.jsonpath.Function;
import com.jayway.jsonpath.internal.EvaluationContext;
import com.jayway.jsonpath.internal.PathRef;
import net.minidev.json.JSONArray;

import java.util.*;

/**
 * Provides the length of a JSONArray Object
 *
 * Created by mattg on 6/26/15.
 */
public class Length implements Function {

    @Override
    public Object invoke(String currentPath, PathRef parent, Object model, EvaluationContext ctx) {
        if (model instanceof Collection) {
            return Integer.valueOf(((Collection) model).size());
        }
        else if (model instanceof Map) {
            return Integer.valueOf(((Map) model).size());
        }
        return null;
    }
}
{'fraction_non_alphanumeric': 0.1023200475907198, 'fraction_numerical': 0.00594883997620464, 'mean_word_length': 3.2261306532663316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4742399', 'n_tokens_mistral': 480, 'n_tokens_neox': 460, 'n_words': 127}