Enum ServiceRegistry

java.lang.Object
java.lang.Enum<ServiceRegistry>
me.lokka30.treasury.api.common.service.ServiceRegistry
All Implemented Interfaces:
Serializable, Comparable<ServiceRegistry>, java.lang.constant.Constable

public enum ServiceRegistry extends Enum<ServiceRegistry>
Represents the place where services are registered and unregistered.

An example service would be that for a EconomyProvider.

Since:
v1.1.0
Author:
MrIvanPlays
  • Enum Constant Details

  • Method Details

    • values

      public static ServiceRegistry[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static ServiceRegistry valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
      NullPointerException - if the argument is null
    • registerService

      public <T> void registerService(@NotNull @NotNull Class<T> clazz, @NotNull T service, @NotNull @NotNull String registrar, @NotNull @NotNull ServicePriority priority)
      Register a provider of a service.
      Type Parameters:
      T - provider
      Parameters:
      clazz - service class
      service - service to register
      registrar - who registers this provider
      priority - priority of the service
    • unregisterAll

      public void unregisterAll(@NotNull @NotNull String registrar)
      Unregister all services from a particular registrar.
      Parameters:
      registrar - the registrar
    • unregister

      public void unregister(@NotNull @NotNull Class<?> clazz, @NotNull @NotNull Object service)
      Unregister a particular service.
      Parameters:
      clazz - service class
      service - service
    • hasRegistration

      public boolean hasRegistration(@NotNull @NotNull Class<?> clazz)
      Returns whether the specified service class has a registration.
      Parameters:
      clazz - class to check
      Returns:
      boolean value
    • serviceFor

      public <T> Optional<Service<T>> serviceFor(@NotNull @NotNull Class<T> clazz)
      Queries for a service with the specified Class.
      Type Parameters:
      T - service type
      Parameters:
      clazz - the class to search a service for
      Returns:
      service or an empty optional if not present
    • allServicesFor

      public <T> Set<Service<T>> allServicesFor(@NotNull @NotNull Class<T> clazz)
      Returns a Set copy of all the services found with the provided Class. If there are no services, it returns an empty set.
      Type Parameters:
      T - service type
      Parameters:
      clazz - class to find the services of
      Returns:
      services