Skip to content

Instantly share code, notes, and snippets.

@adamw
Created January 21, 2020 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamw/9881163e7fc183bd5bff5f302343e89c to your computer and use it in GitHub Desktop.
Save adamw/9881163e7fc183bd5bff5f302343e89c to your computer and use it in GitHub Desktop.
class Example2 {
private final Database database;
Example2(Database database) {
this.database = database;
}
boolean activateUser(Long userId) {
User user = database.findUser(userId);
if (user != null && !user.isActive()) {
database.activateUser(userId);
return true;
} else {
return false;
}
}
}
interface Database {
User findUser(Long id);
void activateUser(Long id);
}
interface User {
boolean isActive();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment