Enum Class Scheme
- All Implemented Interfaces:
Serializable,Comparable<Scheme>,Constable
Enum representing different schemes (protocols) supported by the system.
The Scheme enum defines various network protocols such as HTTP, HTTPS, WS, and WSS.
Each scheme is associated with a specific server type. The scheme can be used to determine the appropriate server
to handle network requests, whether it be an HTTP server or WebSocket server.
- Since:
- 3.3.2-SNAPSHOT
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionHTTP protocol scheme, associated with aWebServer.HTTPS protocol scheme, associated with aWebServer.WebSocket protocol scheme, associated with aWebSocketServer.Secure WebSocket protocol scheme, associated with aWebSocketServer. -
Method Summary
Modifier and TypeMethodDescriptiongetName()Gets the name of the scheme.@NotNull ServerRetrieves the appropriate server instance for the current scheme.Gets the raw server class type associated with the current scheme.getSsl(boolean ssl) Returns the scheme with or without SSL support.booleanisSameFamily(Scheme that) Checks if the specified scheme is from the same scheme family as this scheme.static SchemeReturns the enum constant of this class with the specified name.static Scheme[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
HTTP
HTTP protocol scheme, associated with aWebServer. -
HTTPS
HTTPS protocol scheme, associated with aWebServer. -
WS
WebSocket protocol scheme, associated with aWebSocketServer. -
WSS
Secure WebSocket protocol scheme, associated with aWebSocketServer.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getName
Gets the name of the scheme.- Returns:
- A string representing the scheme name (e.g., "http", "wss").
-
getSsl
Returns the scheme with or without SSL support.If SSL is requested, it returns the HTTPS or WSS variant; otherwise, it returns the HTTP or WS variant.
- Parameters:
ssl- A boolean indicating whether SSL is enabled or not.- Returns:
- The corresponding
Schemewith or without SSL.
-
getServer
Retrieves the appropriate server instance for the current scheme.- Parameters:
craftsNet- TheCraftsNetinstance used to access the servers.- Returns:
- The server instance associated with the current scheme.
- Throws:
UnknownSchemeException- If no server instance is found for the current scheme.
-
getServerRaw
Gets the raw server class type associated with the current scheme.- Returns:
- The class type of the server associated with the current scheme.
-
isSameFamily
Checks if the specified scheme is from the same scheme family as this scheme.- Parameters:
that- The scheme to check.- Returns:
trueif the specified scheme is from the same family,falseotherwise.
-