Remove JdbcMapper.WarnOnUnusedParams param in favor of prefixing unused params with _

This commit is contained in:
Travis Burtrum 2019-02-09 00:16:21 -05:00
parent 664c00a5b2
commit 267e438ac0
4 changed files with 5 additions and 14 deletions

View File

@ -66,13 +66,6 @@ public interface JdbcMapper extends Closeable {
String arrayStringTypeName() default "";
}
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.METHOD})
/**
* Instead of a compile-time error this will only warn on unused params, mainly for debugging or presenting an unfinished API
*/
public @interface WarnOnUnusedParams {}
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.METHOD})
/**

View File

@ -327,7 +327,6 @@ public class JdbcMapperProcessor extends AbstractProcessor {
lookupCloseMethod = false;
continue; // skip close method
}
final JdbcMapper.WarnOnUnusedParams warnOnUnusedParams = eeMethod.getAnnotation(JdbcMapper.WarnOnUnusedParams.class);
final JdbcMapper.SQL sql = eeMethod.getAnnotation(JdbcMapper.SQL.class);
if (sql == null || sql.value().isEmpty()) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "@JdbcMapper.SQL with non-empty query is required on abstract or interface methods", methodElement);
@ -503,8 +502,9 @@ public class JdbcMapperProcessor extends AbstractProcessor {
*/
} else if(isPrimitiveInteger(unusedType.getKind()) && maxRows == null && this.allowedMaxRowParamNames.contains(unusedParam.getKey())) {
maxRows = CompileTimeResultSetMapper.MaxRows.getMaxRows(unusedParam.getKey(), unusedType.toString());
} else
processingEnv.getMessager().printMessage(warnOnUnusedParams != null ? Diagnostic.Kind.MANDATORY_WARNING : Diagnostic.Kind.ERROR, String.format("@JdbcMapper.SQL method has unused parameter '%s'", unusedParam.getKey()), unusedParam.getValue());
} else if(!unusedParam.getKey().startsWith("_")) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, String.format("@JdbcMapper.SQL method has unused parameter '%s' (rename to start with _ to suppress error)", unusedParam.getKey()), unusedParam.getValue());
}
}
}
final boolean notBindInList = !inListBindParams.isEmpty() && databaseType != JdbcMapper.DatabaseType.BIND;

View File

@ -53,9 +53,8 @@ public interface PersonDAO extends JdbcMapper {
@JdbcMapper.SQL("SELECT person_no FROM person WHERE last_name = {lastName}")
long getPersonNo(String lastName) throws SQLException;
@JdbcMapper.WarnOnUnusedParams
@JdbcMapper.SQL("SELECT person_no FROM person WHERE last_name = {lastName}")
long getPersonNoUnusedParam(String lastName, String unused) throws SQLException;
long getPersonNoUnusedParam(String lastName, String _bla) throws SQLException;
@JdbcMapper.SQL("SELECT first_name, last_name FROM person WHERE last_name = {lastName}")
ResultSet getPeopleResultSet(String lastName) throws SQLException;

View File

@ -53,9 +53,8 @@ public interface PrestoPersonDAO extends PersonDAO {
@JdbcMapper.SQL("SELECT person_no FROM person WHERE last_name = {lastName}")
long getPersonNo(String lastName) throws SQLException;
@JdbcMapper.WarnOnUnusedParams
@JdbcMapper.SQL("SELECT person_no FROM person WHERE last_name = {lastName}")
long getPersonNoUnusedParam(String lastName, String unused) throws SQLException;
long getPersonNoUnusedParam(String lastName, String _bla) throws SQLException;
@JdbcMapper.SQL("SELECT first_name, last_name FROM person WHERE last_name = {lastName}")
ResultSet getPeopleResultSet(String lastName) throws SQLException;