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

com.bixuebihui.r2dbc.sql.RowMapperResultReaderToMap Maven / Gradle / Ivy

The newest version!
package com.bixuebihui.r2dbc.sql;

import io.r2dbc.spi.Result;
import reactor.core.publisher.Mono;

import java.util.HashMap;
import java.util.Map;

/**
 * 

RowMapperResultReaderToMap class.

* * @author xingwx * @version $Id: $Id */ public class RowMapperResultReaderToMap { private RowMapper handle; private String keyName; private Map res; /** *

Constructor for RowMapperResultReaderToMap.

* * @param handle a {@link RowMapper} object. * @param keyName a {@link String} object. */ public RowMapperResultReaderToMap(RowMapper handle, String keyName){ this.handle = handle; this.keyName = keyName; } /** *

Constructor for RowMapperResultReaderToMap.

* * @param handle a {@link RowMapper} object. * @param keyName a {@link String} object. * @param resultMap a {@link Map} object. */ public RowMapperResultReaderToMap(RowMapper handle, String keyName, Map resultMap){ this.handle = handle; this.keyName= keyName; this.res = resultMap; } /** *

processResultSet.

* * @param rs a {@link Result} object. * @return a {@link Map} object. */ @SuppressWarnings("unchecked") public Map processResultSet(Result rs) { if(res ==null) { res = new HashMap<>(); }else{ res.clear(); } Mono.from( rs.map((row, meta) -> res.put((K)row.get(keyName), handle.mapRow(row)))).block(); return res; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy