Package dev.qixils.crowdcontrol.builder
Class CrowdControlClientBuilder
- java.lang.Object
-
- dev.qixils.crowdcontrol.builder.CrowdControlClientBuilder
-
- All Implemented Interfaces:
CrowdControlBuilder
public final class CrowdControlClientBuilder extends Object
Builds a newCrowdControl
instance that acts as a client and connects to a single Crowd Control server instance.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
port
The port that the client/server will connect to or listen on.protected @NotNull Function<@NotNull CrowdControl,@NotNull SocketManager>
socketManagerCreator
A function (usually a constructor) that creates a newSocketManager
given aCrowdControl
instance.
-
Constructor Summary
Constructors Constructor Description CrowdControlClientBuilder()
Creates a newCrowdControl
client builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull CrowdControl
build()
Builds a newCrowdControl
instance using the provided variables.@NotNull CrowdControlClientBuilder
ip(@NotNull String IP)
Sets the IP that the Crowd Control client will connect to.@NotNull CrowdControlClientBuilder
port(int port)
Sets the port that will be used by the Crowd Control client.
-
-
-
Field Detail
-
socketManagerCreator
@NotNull protected final @NotNull Function<@NotNull CrowdControl,@NotNull SocketManager> socketManagerCreator
A function (usually a constructor) that creates a newSocketManager
given aCrowdControl
instance.
-
port
protected int port
The port that the client/server will connect to or listen on.
-
-
Constructor Detail
-
CrowdControlClientBuilder
@CheckReturnValue public CrowdControlClientBuilder()
Creates a newCrowdControl
client builder.
-
-
Method Detail
-
ip
@CheckReturnValue @Contract("_ -> this") @NotNull public @NotNull CrowdControlClientBuilder ip(@NotNull @NotNull String IP) throws IllegalArgumentException
Sets the IP that the Crowd Control client will connect to.- Parameters:
IP
- IP to connect to- Returns:
- this builder
- Throws:
IllegalArgumentException
- the IP was null or blank
-
port
@CheckReturnValue @Contract("_ -> this") @NotNull public @NotNull CrowdControlClientBuilder port(int port) throws IllegalArgumentException
Sets the port that will be used by the Crowd Control client.- Specified by:
port
in interfaceCrowdControlBuilder
- Parameters:
port
- port to connect to- Returns:
- this builder
- Throws:
IllegalArgumentException
- the port was outside the expected bounds of [1,65536]
-
build
@Contract("-> new") @NotNull public @NotNull CrowdControl build() throws IllegalStateException
Builds a newCrowdControl
instance using the provided variables.- Returns:
- new CrowdControl instance
- Throws:
IllegalStateException
-port(int)
orip(String)
was not called
-
-