Class RequirementRegistry
java.lang.Object
de.craftsblock.craftsnet.api.requirements.RequirementRegistry
The
RequirementRegistry class manages the registration and unregistration of Requirement.- Since:
- 3.2.1-SNAPSHOT
-
Constructor Summary
ConstructorsConstructorDescriptionRequirementRegistry(CraftsNet craftsNet) Constructs a new instance of theRequirementRegistry -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the instance ofCraftsNetbound to the registry.ConcurrentHashMap<Class<? extends Server>,ConcurrentLinkedQueue<Requirement<? extends RequireAble, RouteRegistry.EndpointMapping>>> Get all registered requirement processors.getRequirements(Class<? extends Server> server) Get all registered requirement processors for a specific server system.booleanisRegistered(WebRequirement handler) Checks if the givenWebRequirementis registered.booleanisRegistered(WebSocketRequirement<? extends RequireAble> handler) Checks if the givenWebSocketRequirementis registered.booleanisRegistered(Class<? extends Requirement<? extends RequireAble, RouteRegistry.EndpointMapping>> type) Checks if the given class representation of theRequirementis registered.voidloadRequirements(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.voidregister(WebRequirement requirement) Registers and applies a new requirement to the web system.voidregister(WebRequirement requirement, boolean process) Registers a new requirement to the web system.voidregister(WebSocketRequirement<? extends RequireAble> requirement) Registers and applies a new requirement to the websocket system.voidregister(WebSocketRequirement<? extends RequireAble> requirement, boolean process) Registers a new requirement to the websocket system.
-
Constructor Details
-
RequirementRegistry
Constructs a new instance of theRequirementRegistry- Parameters:
craftsNet- The CraftsNet instance which instantiates this requirement registry
-
-
Method Details
-
register
Registers and applies a new requirement to the web system.- Parameters:
requirement- The requirement which should be registered.
-
register
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
Registers and applies a new requirement to the websocket system.- Parameters:
requirement- The requirement which should be registered.
-
register
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
Checks if the givenWebRequirementis registered. This class is a wrapper forisRegistered(Class).- Parameters:
handler- TheWebRequirementto check.- Returns:
truewhen theWebRequirementwas registered,falseotherwise.
-
isRegistered
Checks if the givenWebSocketRequirementis registered. This class is a wrapper forisRegistered(Class).- Parameters:
handler- TheWebSocketRequirementto check.- Returns:
truewhen theWebSocketRequirementwas registered,falseotherwise.
-
isRegistered
public boolean isRegistered(Class<? extends Requirement<? extends RequireAble, RouteRegistry.EndpointMapping>> type) Checks if the given class representation of theRequirementis registered.- Parameters:
type- The class representation of theRequirementto check.- Returns:
truewhen theRequirementwas registered,falseotherwise.
-
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
public ConcurrentHashMap<Class<? extends Server>,ConcurrentLinkedQueue<Requirement<? extends RequireAble, getRequirements()RouteRegistry.EndpointMapping>>> 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
Retrieves the instance ofCraftsNetbound to the registry.- Returns:
- The instance of
CraftsNetbound to the registry.
-