我正在使用一个名为Squeaky的 Android ORM ,它会生成代码以避免使用反射。当我不使用新的千斤顶编译器时,生成的代码可以正常工作,但是使用它我得到了这些错误:
错误:C:\...\app\build\generated\source\apt\prod\debug\...\domain\model\WeatherForecast$Configuration.java:24.20: WeatherForecast$Configuration 类型必须实现继承的抽象方法GeneratedTableMapper.fillRow(WeatherForecast, Cursor, ModelDao, Dao.ForeignRefresh[], TransientCache)
错误:C:\...\app\build\generated\source\apt\prod\debug\...\domain\model\WeatherForecast$Configuration.java:43.15: 方法 fillRow(WeatherForecast, Cursor, ModelDao, Dao WeatherForecast$Configuration 类型的 .ForeignRefresh[], TransientCache) 必须覆盖或实现超类型方法
这实际上是生成代码中的错误还是编译器的错误?
这是生成的有问题的类方法
public final class WeatherForecast$Configuration implements GeneratedTableMapper<WeatherForecast> {
public static final WeatherForecast$Configuration instance = new WeatherForecast$Configuration();
FieldsEnum[] fields;
ForeignCollectionInfo[] foreignConfigs;
public WeatherForecast$Configuration() {
this.fields = getFields();
this.foreignConfigs = getForeignConfigs();
}
@Override
public WeatherForecast createObject(Cursor results) throws SQLException {
WeatherForecast data = new WeatherForecast();
return data;
}
@Override
public void fillRow(WeatherForecast data, Cursor results, ModelDao<WeatherForecast> modelDao, Dao.ForeignRefresh[] foreignRefreshMap, TransientCache objectCache) throws SQLException {
if(!results.isNull(0))data.setStationId(results.getInt(0));
if(!results.isNull(1))data.setTemperature(results.getFloat(1));
if(!results.isNull(2))data.setHumidity(results.getInt(2));
if(!results.isNull(3))data.setForecastCode(results.getInt(3));
if(!results.isNull(4))data.setStartTime(results.getLong(4));
if(!results.isNull(5))data.setEndTime(results.getLong(5));
data.setIcon(results.getString(6));
}
...
}
以及继承/正在使用的 2 个接口:
生成的TableMapper.java
public interface GeneratedTableMapper<T> {
T createObject(Cursor results) throws SQLException;
void fillRow(T data, Cursor results, ModelDao<T> modelDao, Dao.ForeignRefresh[] foreignRefreshMap, TransientCache objectCache) throws SQLException;
void assignId(T data, Object val);
Object extractId(T data);
void bindVals(SQLiteStatement stmt, T data) throws SQLException;
void bindCreateVals(SQLiteStatement stmt, T data) throws SQLException;
String objectToString(T data) throws SQLException;
boolean objectsEqual(T d1, T d2) throws SQLException;
TableInfo<T> getTableConfig() throws SQLException;
void fillForeignCollection(T data, ModelDao<T> modelDao, String fieldName) throws SQLException;
//Foreign
}
道.java
public interface Dao<T> {
class ForeignRefresh {
public final String field;
public final ForeignRefresh[] refreshFields;
public ForeignRefresh(String field) {
this(field, null);
}
public ForeignRefresh(String field, ForeignRefresh[] refreshFields) {
this.field = field;
this.refreshFields = refreshFields;
}
}
interface QueryModifiers<T> {
QueryModifiers<T> orderBy(String s);
QueryModifiers<T> limit(Integer i);
QueryModifiers<T> offset(Integer i);
QueryModifiers<T> foreignRefreshMap(ForeignRefresh[] foreignRefreshMap);
List<T> list() throws SQLException;
}
T queryForId(Object id) throws SQLException;
...
void refresh(T data) throws SQLException;
void refresh(T data, ForeignRefresh[] foreignRefreshMap) throws SQLException;
...
}