1 package au.gov.amsa.ais.router.model;
2
3 import java.util.Optional;
4
5 import com.github.davidmoten.util.Preconditions;
6
7 public final class Proxy {
8 private final String host;
9 private final int port;
10 private final Optional<Authentication> authentication;
11
12 private Proxy(String host, int port, Optional<Authentication> authentication) {
13 Util.verifyNotBlank("host", host);
14 Preconditions.checkNotNull(authentication);
15 this.host = host;
16 this.port = port;
17 this.authentication = authentication;
18 }
19
20 public String host() {
21 return host;
22 }
23
24 public int port() {
25 return port;
26 }
27
28 public Optional<Authentication> getAuthentication() {
29 return authentication;
30 }
31
32 public static Builder builder() {
33 return new Builder();
34 }
35
36 public static class Builder {
37
38 private String host;
39 private int port;
40 private Optional<Authentication> authentication;
41
42 private Builder() {
43 }
44
45 public Builder host(String host) {
46 this.host = host;
47 return this;
48 }
49
50 public Builder port(int port) {
51 this.port = port;
52 return this;
53 }
54
55 public Builder authentication(Optional<Authentication> authentication) {
56 this.authentication = authentication;
57 return this;
58 }
59
60 public Builder authentication(Authentication authentication) {
61 return authentication(Optional.of(authentication));
62 }
63
64 public Proxy build() {
65 return new Proxy(host, port, authentication);
66 }
67 }
68
69 @Override
70 public String toString() {
71 StringBuilder b = new StringBuilder();
72 b.append("Proxy [host=");
73 b.append(host);
74 b.append(", port=");
75 b.append(port);
76 b.append(", authentication=");
77 b.append(authentication);
78 b.append("]");
79 return b.toString();
80 }
81
82 }