Class ViewArguments
java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.service.ViewArguments
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.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ViewArguments.Builderbuilder()Creates a new builder for arguments with any number of entries.static @NotNull ViewArgumentsempty()Returns the shared empty arguments instance.<T> TReturns the value bound to the given key, ornullwhen absent.booleanReturns whether a value is bound to the given key.static @NotNull ViewArgumentsCreates arguments containing a single entry.static @NotNull ViewArgumentsCreates arguments containing two entries.<T> TReturns the value bound to the given key, failing when absent.
-
Method Details
-
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 keyvalue- 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 keyv1- the first entry valuek2- the second entry keyv2- the second entry value- Returns:
- immutable arguments with two entries
-
builder
Creates a new builder for arguments with any number of entries.- Returns:
- a fresh builder
-
get
Returns the value bound to the given key, ornullwhen absent.- Type Parameters:
T- the value type- Parameters:
key- the entry keytype- the expected value type- Returns:
- the typed value, or
nullwhen the key is absent - Throws:
IllegalArgumentException- if a value is present but not assignable totype
-
require
Returns the value bound to the given key, failing when absent.- Type Parameters:
T- the value type- Parameters:
key- the entry keytype- the expected value type- Returns:
- the typed value, never
null - Throws:
IllegalArgumentException- if the key is absent or the value is not assignable totype
-
has
Returns whether a value is bound to the given key.- Parameters:
key- the entry key- Returns:
truewhen the key is present
-