java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.service.ViewArguments

public final class ViewArguments extends Object
Immutable, typed key-value arguments passed to a view when it is opened.

Use builder() for more than two key-value pairs; the of(...) overloads stop at two.

  • Method Details

    • empty

      @NotNull public static @NotNull ViewArguments empty()
      Returns the shared empty arguments instance.
      Returns:
      arguments containing no entries
    • of

      @NotNull public static @NotNull ViewArguments of(@NotNull @NotNull String key, @NotNull @NotNull Object value)
      Creates arguments containing a single entry.
      Parameters:
      key - the entry key
      value - the entry value
      Returns:
      immutable arguments with one entry
    • of

      @NotNull public static @NotNull ViewArguments of(@NotNull @NotNull String k1, @NotNull @NotNull Object v1, @NotNull @NotNull String k2, @NotNull @NotNull Object v2)
      Creates arguments containing two entries.
      Parameters:
      k1 - the first entry key
      v1 - the first entry value
      k2 - the second entry key
      v2 - the second entry value
      Returns:
      immutable arguments with two entries
    • builder

      @NotNull public static @NotNull ViewArguments.Builder builder()
      Creates a new builder for arguments with any number of entries.
      Returns:
      a fresh builder
    • get

      @Nullable public <T> T get(@NotNull @NotNull String key, @NotNull @NotNull Class<T> type)
      Returns the value bound to the given key, or null when absent.
      Type Parameters:
      T - the value type
      Parameters:
      key - the entry key
      type - the expected value type
      Returns:
      the typed value, or null when the key is absent
      Throws:
      IllegalArgumentException - if a value is present but not assignable to type
    • require

      @NotNull public <T> T require(@NotNull @NotNull String key, @NotNull @NotNull Class<T> type)
      Returns the value bound to the given key, failing when absent.
      Type Parameters:
      T - the value type
      Parameters:
      key - the entry key
      type - the expected value type
      Returns:
      the typed value, never null
      Throws:
      IllegalArgumentException - if the key is absent or the value is not assignable to type
    • has

      public boolean has(@NotNull @NotNull String key)
      Returns whether a value is bound to the given key.
      Parameters:
      key - the entry key
      Returns:
      true when the key is present