So I trying to use list of wrapper class as iterator in batch. below is the code I have tried so far
Iterable class
public class AccountCustomIterator implements Iterable<AccountWrapper>, Iterator<AccountWrapper>
{
public List<AccountWrapper> lstAccountWrapper;
Integer i {get; set;}
public AccountCustomIterator(List<AccountWrapper> lstAccountWrapper)
{
this.lstAccountWrapper = lstAccountWrapper;
i = 0;
}
public Boolean hasNext()
{
return (i >= lstAccountWrapper.size()) ? false : true;
}
public AccountWrapper next()
{
if(i < lstAccountWrapper.size())
{
i = i+1;
return lstAccountWrapper[i-1];
}
return null;
}
public Iterator<AccountWrapper> iterator()
{
return this;
}
public class AccountWrapper
{
public String strUnique = '';
public List<Account> lstAccount = new List<Account>();
public AccountWrapper(String strUnique, List<Account> lstAccount)
{
this.strUnique = strUnique;
this.lstAccount = lstAccount;
}
}
}
And here is the batch class
global class AccountChildrecordsUpdateBatch implements Database.batchable<AccountCustomIterator.AccountWrapper>
{
global Iterator<AccountCustomIterator.AccountWrapper> start(Database.BatchableContext BC)
{
List<AccountCustomIterator.AccountWrapper> lst = new List<AccountCustomIterator.AccountWrapper>();
return new AccountCustomIterator(lst);
}
global void execute(Database.BatchableContext BC, List<AccountCustomIterator.AccountWrapper> scope)
{
}
global void finish(Database.BatchableContext BC)
{
}
}
unable to save the batch file getting below error
line 1, col 14. Class AccountChildrecordsUpdateBatch must implement the method: System.Iterable Database.Batchable.start(Database.BatchableContext)