Enum Class Scheme

java.lang.Object
java.lang.Enum<Scheme>
de.craftsblock.craftsnet.api.utils.Scheme
All Implemented Interfaces:
Serializable, Comparable<Scheme>, Constable

public enum Scheme extends Enum<Scheme>
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
  • Enum Constant Details

    • HTTP

      public static final Scheme HTTP
      HTTP protocol scheme, associated with a WebServer.
    • HTTPS

      public static final Scheme HTTPS
      HTTPS protocol scheme, associated with a WebServer.
    • WS

      public static final Scheme WS
      WebSocket protocol scheme, associated with a WebSocketServer.
    • WSS

      public static final Scheme WSS
      Secure WebSocket protocol scheme, associated with a WebSocketServer.
  • Method Details

    • values

      public static Scheme[] 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

      public static Scheme valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • getName

      public String getName()
      Gets the name of the scheme.
      Returns:
      A string representing the scheme name (e.g., "http", "wss").
    • getSsl

      public Scheme getSsl(boolean ssl)
      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 Scheme with or without SSL.
    • getServer

      @NotNull public @NotNull Server getServer(@NotNull @NotNull CraftsNet craftsNet)
      Retrieves the appropriate server instance for the current scheme.
      Parameters:
      craftsNet - The CraftsNet instance 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

      public Class<? extends Server> 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

      public boolean isSameFamily(Scheme that)
      Checks if the specified scheme is from the same scheme family as this scheme.
      Parameters:
      that - The scheme to check.
      Returns:
      true if the specified scheme is from the same family, false otherwise.