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

cc.owoo.godpen.content.html.extract.function.MapFunction Maven / Gradle / Ivy

package cc.owoo.godpen.content.html.extract.function;

import cc.owoo.godpen.content.html.extract.ArrayResult;
import cc.owoo.godpen.content.html.extract.FunctionHandler;
import cc.owoo.godpen.content.html.extract.MapResult;

/**
 * 将数组转换成Map
 * Created by nimensei
 * 2022-11-09 上午 12:17
 */
public class MapFunction extends FunctionHandler {
    @Override
    protected Object handler(ArrayResult arrayResult) {
        MapResult mapResult = new MapResult();
        for (Object object : arrayResult) {
            if (!(object instanceof MapResult map))
                continue;
            Object key = map.get("key");
            Object value = map.get("value");
            if (key != null && value != null)
                mapResult.put(key.toString(), value);
        }
        return mapResult.size() == 0 ? null : mapResult;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy