Skip to content

Commit 3e91677

Browse files
committed
Deprecate old port/secure builder for combo method
1 parent bacf028 commit 3e91677

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/main/java/org/kitteh/irc/client/library/Client.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@ interface Bind {
138138
* Server builder methods.
139139
*/
140140
interface Server {
141+
/**
142+
* The security type, TLS or no.
143+
*/
144+
enum SecurityType {
145+
/**
146+
* TLS enabled.
147+
*/
148+
SECURE,
149+
/**
150+
* TLS disabled.
151+
*/
152+
INSECURE;
153+
}
154+
141155
/**
142156
* Sets the server host and port to which the client will connect.
143157
* <p>
@@ -167,9 +181,22 @@ interface Server {
167181
*
168182
* @param port IRC server port
169183
* @return this builder
184+
* @deprecated use {@link #port(int, SecurityType)} instead
170185
*/
186+
@Deprecated
171187
@NonNull Server port(int port);
172188

189+
/**
190+
* Sets the server port to which the client will connect and
191+
* determines TLS setting. By default, the port is 6697 and the
192+
* TLS setting is {@link SecurityType#SECURE}.
193+
*
194+
* @param port IRC server port
195+
* @param security TLS security setting
196+
* @return this builder
197+
*/
198+
@NonNull Server port(int port, @NonNull SecurityType security);
199+
173200
/**
174201
* Sets the server password.
175202
* <p>
@@ -190,7 +217,9 @@ interface Server {
190217
*
191218
* @param secure true for TLS
192219
* @return this builder
220+
* @deprecated use {@link #port(int, SecurityType)} instead
193221
*/
222+
@Deprecated
194223
@NonNull Server secure(boolean secure);
195224

196225
/**

src/main/java/org/kitteh/irc/client/library/defaults/DefaultBuilder.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,27 @@ private class ServerImpl implements Server {
100100
return this;
101101
}
102102

103+
@Deprecated
103104
@Override
104105
public @NonNull Server port(int port) {
105106
DefaultBuilder.this.serverHostWithPort = DefaultBuilder.this.serverHostWithPort.withPort(DefaultBuilder.this.isValidPort(port));
106107
return this;
107108
}
108109

110+
@Override
111+
public @NonNull Server port(int port, @NonNull SecurityType security) {
112+
DefaultBuilder.this.serverHostWithPort = DefaultBuilder.this.serverHostWithPort.withPort(DefaultBuilder.this.isValidPort(port));
113+
DefaultBuilder.this.secure = security != SecurityType.INSECURE; // Default to secure on null
114+
return this;
115+
}
116+
109117
@Override
110118
public @NonNull Server password(@Nullable String password) {
111119
DefaultBuilder.this.serverPassword = password;
112120
return this;
113121
}
114122

123+
@Deprecated
115124
@Override
116125
public @NonNull Server secure(boolean secure) {
117126
DefaultBuilder.this.secure = secure;

0 commit comments

Comments
 (0)