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
final class DiskPersistence { | |
private final static DiskPersistence instance = new DiskPersistence(); | |
public static DiskPersistence getInstance() { | |
return instance; | |
} | |
private DiskPersistence() { | |
// prevents to create a new instance |
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(); | |
} | |
static class EmptyPersistence implements Persistence { | |
private static Persistence persistence; | |
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(); | |
} | |
static class EmptyPersistence implements Persistence { | |
@Override void delete(){ | |
} | |
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 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
public class LoginFragment extends Fragment { | |
void onLoginClicked(){} | |
void makeLoginRequest(){} | |
void displayHome(){} | |
void onRegisterClicked(){} | |
void displayRegistrationFragment(){} | |
} |
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
public class Account { | |
private final User user; | |
private final String id; | |
public Account(AccountResponse response) { | |
id = response.id; | |
user = User.newUser(response.userResponse); | |
} | |
} |
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
public class User { | |
private final String id; | |
private final String name; | |
public User(UserResponse response) { | |
if (response != null) { | |
id = response.id; | |
name = response.name; | |
} | |
} |
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
public class Account { | |
private final User user; | |
private final String id; | |
public Account(AccountResponse response) { | |
id = response.id; | |
UserResponse userResponse = response.userResponse; | |
if (userResponse != null) { | |
user = new User(response.userResponse); | |
} |
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
public class Account { | |
private final User user; | |
private final String id; | |
public Account(AccountResponse response) { | |
id = response.id; | |
user = new User(response.userResponse); | |
} | |
} |
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
public class MyFragment extends Fragment { | |
private static final String KEY_NAME = "KEY_NAME"; | |
public static Fragment newFragment(String name) { | |
Fragment fragment = new MyFragment(); | |
Bundle bundle = new Bundle(); | |
bundle.putExtra(KEY_NAME, name); | |
fragment.setArguments(bundle); | |
return fragment; | |
} |