public class MapperGenerator extends AbstractGenerator
Modifier and Type | Field and Description |
---|---|
private static String |
SPRING_ROW_MAPPER |
Constructor and Description |
---|
MapperGenerator(ProcessingEnvironment processingEnv) |
Modifier and Type | Method and Description |
---|---|
private com.sun.codemodel.JDefinedClass |
createClass(com.sun.codemodel.JCodeModel model,
String qualifiedClassName,
com.sun.codemodel.JClass typeJClass)
Generates:
class *Mapper implements RowMapper<*> [className, typeJClass]
|
private void |
createMapRow(com.sun.codemodel.JCodeModel model,
com.sun.codemodel.JDefinedClass mapperClass,
com.sun.codemodel.JClass type,
List<Variable> mapperVariables)
Generates:
public * mapRow(ResultSet rs, int rowNum) throws SQLException {
return new * ( [ rs.get*(*) ]* );
}
|
private void |
generateMapper(MapperClass mapperClass)
Generates a MapperClass.
|
void |
generateMappers(Collection<MapperClass> mapperClasses) |
private static String |
getResultSetMethod(String type)
Retrieves the most fitting
ResultSet method based on the type. |
generateClass
private static final String SPRING_ROW_MAPPER
public MapperGenerator(ProcessingEnvironment processingEnv)
public void generateMappers(Collection<MapperClass> mapperClasses) throws com.sun.codemodel.JClassAlreadyExistsException, ClassNotFoundException, IOException
com.sun.codemodel.JClassAlreadyExistsException
ClassNotFoundException
IOException
private void generateMapper(MapperClass mapperClass) throws com.sun.codemodel.JClassAlreadyExistsException, ClassNotFoundException, IOException
Example:
public class *Mapper implements RowMapper<*> { public T mapRow(ResultSet rs, int rowNum) throws SQLException { return new T( [rs.*(1)]+ ); } }
mapperClass
- the mapper classcom.sun.codemodel.JClassAlreadyExistsException
ClassNotFoundException
IOException
private com.sun.codemodel.JDefinedClass createClass(com.sun.codemodel.JCodeModel model, String qualifiedClassName, com.sun.codemodel.JClass typeJClass) throws com.sun.codemodel.JClassAlreadyExistsException
class *Mapper implements RowMapper<*> [className, typeJClass]
com.sun.codemodel.JClassAlreadyExistsException
private void createMapRow(com.sun.codemodel.JCodeModel model, com.sun.codemodel.JDefinedClass mapperClass, com.sun.codemodel.JClass type, List<Variable> mapperVariables) throws ClassNotFoundException
public * mapRow(ResultSet rs, int rowNum) throws SQLException { return new * ( [ rs.get*(*) ]* ); }
ClassNotFoundException
Copyright © 2015. All rights reserved.