Skip to content

Instantly share code, notes, and snippets.

@fjkz
Created February 23, 2020 04:15
Show Gist options
  • Save fjkz/ea602e74b846c8bf4505adf7d275a940 to your computer and use it in GitHub Desktop.
Save fjkz/ea602e74b846c8bf4505adf7d275a940 to your computer and use it in GitHub Desktop.
Builder pattern
class SshClient {
SshClient(String user, String host, int port, int timeout) {
// ...
}
SshClient(String user, String host) {
this(user, host, 22, 60);
}
SshClient(String user, String host, int port) {
this(user, host, port, 60);
}
SshClient(String user, String host, int timeout) { // <- compile error
this(user, host, 22, timeout);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment