Last active
October 12, 2015 09:49
-
-
Save orhanobut/c45de6e1ed8dd1d1b23b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Persistence { | |
void delete(); | |
void add(String value); | |
String get(); | |
} | |
class FooBar { | |
private Persistence persistence; | |
void persistence(Persistence persistence) { | |
this.persistence = persistence; | |
} | |
private void delete() { | |
// some different things to handle | |
if (persistence != null) { | |
persistence.delete(); | |
} | |
} | |
private String get() { | |
if (persistence != null) { | |
return persistence.get(); | |
} | |
return null; | |
} | |
private void save(String value) { | |
if (persistence != null) { | |
persistence.save(value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment