3 answers
If you do not want to start the batch if a condition fails to return a QueryLocator instead of an iterable, you can return a QueryLocator with a query that you know will not return any records. ex:
String sql;
if(runBatch) {
sql = ' Select Id from Account where city__c ='NewYork' ; // query to use if the condition is met
} else {
sql = 'SELECT Id FROM Account WHERE IsDeleted=true AND IsDeleted=false'; // query that is known in advance that no record will return
}
return Database.getQueryLocator(sql);