Last active
September 27, 2017 13:51
-
-
Save sizovs/4c722960c2ce07e735e175870b1c81b0 to your computer and use it in GitHub Desktop.
deps.java
This file contains hidden or 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
class Customer1 { | |
void change(String password); | |
} | |
class Customer2 { | |
void change(Password password) { | |
} | |
} | |
interface Password { | |
String raw(); | |
} | |
class VaultPassword implements Password { | |
private final Vault vault; | |
private final Supplier<String> password; | |
public VaultPassword(Vault vault) { | |
this.vault = vault; | |
this.password = Suppliers.memoize(vault::verySecurePassword()); | |
} | |
@Override | |
public String raw() { | |
return password.get(); | |
} | |
} | |
class Vault { | |
public void verySecurePassword() { | |
// remote call! omg omg omg! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment