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 newCrowdControlinstance that acts as a client and connects to a single Crowd Control server instance.
-
-
Field Summary
Fields Modifier and Type Field Description protected intportThe port that the client/server will connect to or listen on.protected @NotNull Function<@NotNull CrowdControl,@NotNull SocketManager>socketManagerCreatorA function (usually a constructor) that creates a newSocketManagergiven aCrowdControlinstance.
-
Constructor Summary
Constructors Constructor Description CrowdControlClientBuilder()Creates a newCrowdControlclient builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull CrowdControlbuild()Builds a newCrowdControlinstance using the provided variables.@NotNull CrowdControlClientBuilderip(@NotNull String IP)Sets the IP that the Crowd Control client will connect to.@NotNull CrowdControlClientBuilderport(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 newSocketManagergiven aCrowdControlinstance.
-
port
protected int port
The port that the client/server will connect to or listen on.
-
-
Constructor Detail
-
CrowdControlClientBuilder
@CheckReturnValue public CrowdControlClientBuilder()
Creates a newCrowdControlclient builder.
-
-
Method Detail
-
ip
@CheckReturnValue @Contract("_ -> this") @NotNull public @NotNull CrowdControlClientBuilder ip(@NotNull @NotNull String IP) throws IllegalArgumentExceptionSets 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 IllegalArgumentExceptionSets the port that will be used by the Crowd Control client.- Specified by:
portin 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 IllegalStateExceptionBuilds a newCrowdControlinstance using the provided variables.- Returns:
- new CrowdControl instance
- Throws:
IllegalStateException-port(int)orip(String)was not called
-
-