class JSONPathSingleIndex
        extends JSONPathSingle {
    final JSONPathSegmentIndex segment;
    final int index;

    public JSONPathSingleIndex(String path, JSONPathSegmentIndex segment, Feature... features) {
        super(segment, path, features);
        this.segment = segment;
        this.index = segment.index;
    }

    @Override
    public Object eval(Object object) {
        if (object == null) {
            return null;
        }

        if (object instanceof java.util.List) {
            Object value = null;
            List list = (List) object;
            if (index < list.size()) {
                value = list.get(index);
            }
            return value;
        }

        Context context = new Context(this, null, segment, null, 0);
        context.root = object;
        segment.eval(context);
        return context.value;
    }

    @Override
    public Object extract(JSONReader jsonReader) {<FILL_FUNCTION_BODY>}
}

        if (jsonReader.nextIfNull()) {
            return null;
        }

        int max = jsonReader.startArray();
        if (jsonReader.jsonb && index >= max) {
            return null;
        }

        if ((!jsonReader.jsonb) && jsonReader.nextIfArrayEnd()) {
            return null;
        }

        for (int i = 0; i < index && i < max; i++) {
            jsonReader.skipValue();
            if ((!jsonReader.jsonb) && jsonReader.nextIfArrayEnd()) {
                return null;
            }
        }
        return jsonReader.readAny();
    
<methods>public boolean contains(java.lang.Object) ,public java.lang.Object eval(java.lang.Object) ,public java.lang.Object extract(com.alibaba.fastjson2.JSONReader) ,public java.lang.String extractScalar(com.alibaba.fastjson2.JSONReader) ,public final com.alibaba.fastjson2.JSONPath getParent() ,public boolean isRef() ,public boolean remove(java.lang.Object) ,public void set(java.lang.Object, java.lang.Object) ,public transient void set(java.lang.Object, java.lang.Object, com.alibaba.fastjson2.JSONReader.Feature[]) ,public void setCallback(java.lang.Object, BiFunction#RAW) ,public void setInt(java.lang.Object, int) ,public void setLong(java.lang.Object, long) <variables>final non-sealed boolean extractSupport,final non-sealed boolean ref,final non-sealed com.alibaba.fastjson2.JSONPathSegment segment