001/* 002 * Stallion Core: A Modern Web Framework 003 * 004 * Copyright (C) 2015 - 2016 Stallion Software LLC. 005 * 006 * This program is free software: you can redistribute it and/or modify it under the terms of the 007 * GNU General Public License as published by the Free Software Foundation, either version 2 of 008 * the License, or (at your option) any later version. This program is distributed in the hope that 009 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 011 * License for more details. You should have received a copy of the GNU General Public License 012 * along with this program. If not, see <http://www.gnu.org/licenses/gpl-2.0.html>. 013 * 014 * 015 * 016 */ 017 018package io.stallion.dataAccess.db.converters; 019 020import io.stallion.dataAccess.Model; 021import io.stallion.dataAccess.db.Schema; 022import org.apache.commons.dbutils.handlers.AbstractListHandler; 023 024import java.sql.ResultSet; 025import java.sql.SQLException; 026 027 028public class ModelListHandler<T extends Model> extends AbstractListHandler<T> implements ResultToModel<T> { 029 private Class modelClass; 030 private Schema schema; 031 032 public 033 ModelListHandler(Schema schema) { 034 this.modelClass = schema.getClazz(); 035 this.schema = schema; 036 } 037 038 039 @Override 040 public Class getModelClass() { 041 return modelClass; 042 } 043 044 045 @Override 046 public Schema getSchema() { 047 return schema; 048 } 049 050 @Override 051 protected T handleRow(ResultSet resultSet) throws SQLException { 052 return handleOneRow(resultSet); 053 } 054 055 /* 056 @Override 057 public List<BaseModel> handle(ResultSet resultSet) throws SQLException { 058 059 } 060 */ 061}