com.alibaba.fastjson2.reader.FieldReaderListFuncImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fastjson2 Show documentation
Show all versions of fastjson2 Show documentation
Fastjson is a JSON processor (JSON parser + JSON generator) written in Java
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);
}
}