Skip to content

Instantly share code, notes, and snippets.

@jeremyheiler
Created December 20, 2012 20:15
Show Gist options
  • Save jeremyheiler/4348185 to your computer and use it in GitHub Desktop.
Save jeremyheiler/4348185 to your computer and use it in GitHub Desktop.
public ItemProcessor extends IterativeProcessor<String> implements Processor {
@Override
public List<String> getItems(Request req) {
return req.getParameters("items");
}
@Override
public void processItem(Request req, String item) {
Database.saveItem(item);
}
}
public abstract IterativeProcessor<T> implements Processor {
protected abstract List<T> getItems(Request req);
protected abstract void processItem(Request req, T item);
@Override
public final void process(Request req) {
for (T item : getItems(req)) {
processItem(req, item);
}
}
}
public interface Processor {
public void process(Request req);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment