class CollectionExtractor implements Extractor {

    public Object extractObject(ObjectToJsonConverter pConverter, Object pValue, Stack<String> pPathParts, boolean jsonify) throws AttributeNotFoundException {
        Collection collection = (Collection) pValue;
        String pathPart = pPathParts.isEmpty() ? null : pPathParts.pop();
        int length = pConverter.getCollectionLength(collection.size());
        if (pathPart != null) {
            return extractWithPath(pConverter, collection, pPathParts, jsonify, pathPart, length);
        } else {
            return jsonify ? extractListAsJson(pConverter, collection, pPathParts, length) : collection;
        }
    }

}