Class FunctionRequestManager<T,V>

java.lang.Object
me.hsgamer.hscore.request.FunctionRequestManager<T,V>
Type Parameters:
T - the type of the argument
V - the type of the return value

public class FunctionRequestManager<T,V> extends Object
A simple request manager with return values
  • Constructor Details

    • FunctionRequestManager

      public FunctionRequestManager()
  • Method Details

    • addRequest

      public void addRequest(@NotNull @NotNull UUID uuid, @NotNull @NotNull BiFunction<UUID,T,V> function)
      Add a request
      Parameters:
      uuid - the unique id
      function - the function when the request is called
    • addRequest

      public void addRequest(@NotNull @NotNull UUID uuid, @NotNull @NotNull Function<T,V> function)
      Add a request
      Parameters:
      uuid - the unique id
      function - the function when the request is called
    • apply

      @Nullable public V apply(@NotNull @NotNull UUID uuid, @NotNull T arg)
      Apply a request
      Parameters:
      uuid - the unique id
      arg - the argument
      Returns:
      the return value from the function
    • remove

      public void remove(@NotNull @NotNull UUID uuid)
      Remove a request
      Parameters:
      uuid - the unique id
    • contains

      public boolean contains(@NotNull @NotNull UUID uuid)
      Check if a unique id is in the request cache
      Parameters:
      uuid - the unique id
      Returns:
      whether it's in the request cache