All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.fastjson2.reader.FieldReaderListFuncImpl Maven / Gradle / Ivy

Go to download

Fastjson is a JSON processor (JSON parser + JSON generator) written in Java

There is a newer version: 2.0.53.android8
Show newest version
package com.alibaba.fastjson2.reader;

import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.util.TypeUtils;

import java.lang.reflect.Type;
import java.util.Collection;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Supplier;

class FieldReaderListFuncImpl
        extends FieldReaderList {
    final Supplier> listCreator;
    final ObjectReader itemObjectReader;

    public FieldReaderListFuncImpl(
            Supplier> listCreator,
            ObjectReader itemObjectReader,
            BiConsumer> function,
            Type itemType, String fieldName) {
        super(fieldName, List.class, List.class, itemType, TypeUtils.getClass(itemType), 0, 0, null, null, null, null, null, null, function);
        this.listCreator = listCreator;
        this.itemObjectReader = itemObjectReader;
    }

    @Override
    public Collection createList(JSONReader.Context context) {
        return listCreator.get();
    }

    @Override
    public void accept(T object, Object list) {
        function.accept(object, list);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy