Class RequirementRegistry

java.lang.Object
de.craftsblock.craftsnet.api.requirements.RequirementRegistry

public class RequirementRegistry extends Object
The RequirementRegistry class manages the registration and unregistration of Requirement.
Since:
3.2.1-SNAPSHOT
  • Constructor Details

    • RequirementRegistry

      public RequirementRegistry(CraftsNet craftsNet)
      Constructs a new instance of the RequirementRegistry
      Parameters:
      craftsNet - The CraftsNet instance which instantiates this requirement registry
  • Method Details

    • register

      public void register(WebRequirement requirement)
      Registers and applies a new requirement to the web system.
      Parameters:
      requirement - The requirement which should be registered.
    • register

      public void register(WebRequirement requirement, boolean process)
      Registers a new requirement to the web system. Optional the requirement can be applied to all existing endpoints or only to new ones.
      Parameters:
      requirement - The requirement which should be registered.
      process - Whether if all registered endpoints should receive the new requirement (true) or not (false).
    • register

      public void register(WebSocketRequirement<? extends RequireAble> requirement)
      Registers and applies a new requirement to the websocket system.
      Parameters:
      requirement - The requirement which should be registered.
    • register

      public void register(WebSocketRequirement<? extends RequireAble> requirement, boolean process)
      Registers a new requirement to the websocket system. Optional the requirement can be applied to all existing endpoints or only to new ones.
      Parameters:
      requirement - The requirement which should be registered.
      process - Whether if all registered endpoints should receive the new requirement (true) or not (false).
    • isRegistered

      public boolean isRegistered(WebRequirement handler)
      Checks if the given WebRequirement is registered. This class is a wrapper for isRegistered(Class).
      Parameters:
      handler - The WebRequirement to check.
      Returns:
      true when the WebRequirement was registered, false otherwise.
    • isRegistered

      public boolean isRegistered(WebSocketRequirement<? extends RequireAble> handler)
      Checks if the given WebSocketRequirement is registered. This class is a wrapper for isRegistered(Class).
      Parameters:
      handler - The WebSocketRequirement to check.
      Returns:
      true when the WebSocketRequirement was registered, false otherwise.
    • isRegistered

      public boolean isRegistered(Class<? extends Requirement<? extends RequireAble,RouteRegistry.EndpointMapping>> type)
      Checks if the given class representation of the Requirement is registered.
      Parameters:
      type - The class representation of the Requirement to check.
      Returns:
      true when the Requirement was registered, false otherwise.
    • loadRequirements

      @Internal public void loadRequirements(ConcurrentHashMap<Class<? extends Annotation>,RequirementInfo> requirements, Collection<Class<? extends Annotation>> annotations, Method method, Object handler)
      Load all the requirements from a specific list of annotations for a method and its handler.
      Parameters:
      requirements - A concurrent map where all the processed requirements will be stored.
      annotations - A list of annotation classes to process as requirements.
      method - The method for which the requirements should be loaded.
      handler - The handler object that contains the method and acts as the parent context.
    • getRequirements

      Get all registered requirement processors.
      Returns:
      A map which contains all the requirement processors per server sorted.
    • getRequirements

      public Collection<Requirement<? extends RequireAble,RouteRegistry.EndpointMapping>> getRequirements(Class<? extends Server> server)
      Get all registered requirement processors for a specific server system.
      Parameters:
      server - The server system the requirement processors should be loaded from.
      Returns:
      A list which contains all the requirement processors for the specific server system.
    • getCraftsNet

      public CraftsNet getCraftsNet()
      Retrieves the instance of CraftsNet bound to the registry.
      Returns:
      The instance of CraftsNet bound to the registry.