2014-04-22 14:40:18 -04:00
|
|
|
package com.moparisthebest.jdbc;
|
|
|
|
|
|
|
|
import java.sql.ResultSet;
|
2017-05-17 17:32:48 -04:00
|
|
|
import java.sql.SQLException;
|
2014-04-22 14:40:18 -04:00
|
|
|
import java.util.Calendar;
|
|
|
|
|
2017-05-17 17:32:48 -04:00
|
|
|
public class CleaningRowToObjectMapper<K, T> extends RowToObjectMapper<K, T> {
|
2014-04-22 14:40:18 -04:00
|
|
|
|
|
|
|
private final Cleaner<T> cleaner;
|
|
|
|
|
2017-05-17 17:32:48 -04:00
|
|
|
public CleaningRowToObjectMapper(Cleaner<T> cleaner, ResultSet resultSet, Class<T> returnTypeClass, Calendar cal, Class<?> mapValType, Class<K> mapKeyType) {
|
|
|
|
super(resultSet, returnTypeClass, cal, mapValType, mapKeyType);
|
2014-04-22 14:40:18 -04:00
|
|
|
if (cleaner == null)
|
|
|
|
throw new NullPointerException("cleaner cannot be null!");
|
|
|
|
this.cleaner = cleaner;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-05-17 17:32:48 -04:00
|
|
|
public T mapRowToReturnType() throws SQLException {
|
2014-04-22 14:40:18 -04:00
|
|
|
return cleaner.clean(super.mapRowToReturnType());
|
|
|
|
}
|
|
|
|
}
|