As a follow up to this question I posted yesterday, I have a generic batch job class as so:
public abstract class GenericJob implements Database.Batchable<SObject>, Database.Stateful {
String query;
public void setQuery(String query) {
this.query = query;
}
public String getQuery()
{
return query;
}
public Database.QueryLocator start(Database.BatchableContext context) {
return Database.getQueryLocator(query);
}
public abstract void execute(Database.BatchableContext context, List<sObject> scope);
public void finish(Database.BatchableContext context) {
... // my own finish logic here
doFinish(context);
}
public abstract void doFinish(Database.BatchableContext context); // user defined execute logic
}
As you can see, I have the finish
function where I want to carry out some work of my own, and then give the user the option to perform their own finish logic after I'm done with mine. I would like to allow the user to override the doFinish
function, but how do I prevent them from overriding the finish
(or any of the other functions for that matter)? It seems that overriding any method is just a step away with the override
keyword. I can't make the functions private as they are overriding the same function declarations of the Database.Batchable
interface.
Do I just hope and pray that my client will have the good sense to know what to leave alone? Or is there a way I can actually prevent them from overriding that method unknowingly?
I haven't found a solution to this anywhere. Any help would be appreciated. Thank you!