Skip to content

Instantly share code, notes, and snippets.

@hamstar
Created October 4, 2011 01:12
Show Gist options
  • Select an option

  • Save hamstar/1260692 to your computer and use it in GitHub Desktop.

Select an option

Save hamstar/1260692 to your computer and use it in GitHub Desktop.
Factory save method example
class TaskFactory {
public void save( Task task ) {
HashMap data = new HashMap<>();
data.put("Name", task.getName() );
data.put("Description", task.getDescription() );
// etc...
if ( task.isNew() ) {
db.insert( Table.TASKS.getName(), data );
} else {
db.update( Table.TASKS.getName(), data );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment