Answer the question
In order to leave comments, you need to log in
Interface and return type in Java. How to be?
There is a code:
public interface DfgDbAdaptee {
public boolean checkTableExists(String tableName) throws DfgFatalException;
}
public class DfgDbSqliteAdapter implements DfgDbAdaptee {
public boolean checkTableExists(String tableName) throws DfgFatalException
{
.....
}
}
public class DfgDbFMDBAdapter implements DfgDbAdaptee {
public boolean checkTableExists(String tableName) throws DfgFatalException
{
.....
}
}
public class DfgDb {
public static ??? Factory()
{
int dbType = DfgAppConfig.getDbType();
if (dbType == DfgAppConfig.DBTYPE_SQLITE){
return new DfgDbSqliteAdapter;
}else if (dbType == DfgAppConfig.DBTYPE_FMDB){
return new DfgDbFMDBAdapter;
}
throw new DfgConfigException("Unknown db type in config");
}
}
//и гдето в коде вызываем:
??? db = DfgDb.Factory();
db.checkTableExists(new String("lalala"));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question