Package dev.tachyonmcp.api.server.domain
Class Args
java.lang.Object
dev.tachyonmcp.api.server.domain.Args
- All Implemented Interfaces:
JsonDocument,JsonObject
Arguments container wrapping a
JsonObject with optional deserialization support.-
Method Summary
Modifier and TypeMethodDescriptionReturns the named array, or an empty optional when it is missing or JSON null.asMap()Returns an immutable map representation.Returns the named boolean, or an empty optional when it is missing or JSON null.decimalOpt(String name) Returns the named number without precision loss.<T> TDecodes the full arguments into the given class using the configured serde.<T> TDecodes the full arguments into the given type using the configured serde.Returns the named value converted to a finitedouble.static Argsempty()Returns a shared empty arguments instance.static Argsfrom(JsonObject values, @Nullable PayloadDeserializer deserializer) Creates arguments from a JSON object with a deserializer.booleanReturns whether the object has propertyname, including when its value is JSON null.Returns the named exactint.booleanisEmpty()Returns whether the arguments are empty.json()Returns the encoded JSON value.Returns the named exactlong.Returns the named object, or an empty optional when it is missing or JSON null.static ArgsCreates arguments from a map of values.static Argsof(@Nullable Map<String, ?> values, @Nullable PayloadDeserializer deserializer) Creates arguments from a map of values with a deserializer.rawJson()Returns the full arguments as a JSON string.Returns the named string, or an empty optional when it is missing or JSON null.toString()Returns the JSON representation, so an accidental string concatenation ofArgs(e.g. in a log line or a prompt/tool message) produces readable JSON instead of an opaque object identity.<T> Optional<T> Returns the retained provider-specific representation when it matchestype.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface dev.tachyonmcp.api.json.JsonObject
arrayOr, arrayValue, boolOr, boolValue, decimalOr, decimalValue, doubleOr, doubleValue, intOr, intValue, longOr, longValue, objectOr, objectValue, stringOr, stringValue
-
Method Details
-
of
Creates arguments from a map of values.- Parameters:
values- the argument values, ornullfor empty- Returns:
- a new Args instance
-
empty
Returns a shared empty arguments instance.- Returns:
- empty args
-
of
Creates arguments from a map of values with a deserializer.- Parameters:
values- the argument values, ornullfor emptydeserializer- the payload deserializer, ornull- Returns:
- a new Args instance
-
from
Creates arguments from a JSON object with a deserializer.- Parameters:
values- the JSON object containing argument valuesdeserializer- the payload deserializer, ornull- Returns:
- a new Args instance
-
isEmpty
public boolean isEmpty()Returns whether the arguments are empty.- Returns:
trueif no arguments are present
-
has
Description copied from interface:JsonObjectReturns whether the object has propertyname, including when its value is JSON null.- Specified by:
hasin interfaceJsonObject- Parameters:
name- the property name- Returns:
- true if the property exists
-
objectOpt
Description copied from interface:JsonObjectReturns the named object, or an empty optional when it is missing or JSON null.- Specified by:
objectOptin interfaceJsonObject- Parameters:
name- the property name- Returns:
- the object value, or empty if missing or null
-
arrayOpt
Description copied from interface:JsonObjectReturns the named array, or an empty optional when it is missing or JSON null.- Specified by:
arrayOptin interfaceJsonObject- Parameters:
name- the property name- Returns:
- the array value, or empty if missing or null
-
stringOpt
Description copied from interface:JsonObjectReturns the named string, or an empty optional when it is missing or JSON null.- Specified by:
stringOptin interfaceJsonObject- Parameters:
name- the property name- Returns:
- the string value, or empty if missing or null
-
boolOpt
Description copied from interface:JsonObjectReturns the named boolean, or an empty optional when it is missing or JSON null.- Specified by:
boolOptin interfaceJsonObject- Parameters:
name- the property name- Returns:
- the boolean value, or empty if missing or null
-
decimalOpt
Description copied from interface:JsonObjectReturns the named number without precision loss.- Specified by:
decimalOptin interfaceJsonObject- Parameters:
name- the property name- Returns:
- the decimal value, or empty if missing or null
-
intOpt
Description copied from interface:JsonObjectReturns the named exactint.- Specified by:
intOptin interfaceJsonObject- Parameters:
name- the property name- Returns:
- the int value, or empty if missing or null
-
longOpt
Description copied from interface:JsonObjectReturns the named exactlong.- Specified by:
longOptin interfaceJsonObject- Parameters:
name- the property name- Returns:
- the long value, or empty if missing or null
-
doubleOpt
Description copied from interface:JsonObjectReturns the named value converted to a finitedouble.The conversion may lose precision. Use
JsonObject.decimalOpt(String)when an exact decimal representation is required.- Specified by:
doubleOptin interfaceJsonObject- Parameters:
name- the property name- Returns:
- the double value, or empty if missing or null
-
asMap
Description copied from interface:JsonObjectReturns an immutable map representation.- Specified by:
asMapin interfaceJsonObject- Returns:
- the map view
-
unwrap
Description copied from interface:JsonDocumentReturns the retained provider-specific representation when it matchestype.The default implementation is provider-neutral and returns an empty optional.
- Specified by:
unwrapin interfaceJsonDocument- Type Parameters:
T- the requested representation type- Parameters:
type- the class of the requested representation- Returns:
- the provider-specific representation, or empty if not available
-
json
Description copied from interface:JsonDocumentReturns the encoded JSON value.- Specified by:
jsonin interfaceJsonDocument- Returns:
- the JSON string
-
toString
Returns the JSON representation, so an accidental string concatenation ofArgs(e.g. in a log line or a prompt/tool message) produces readable JSON instead of an opaque object identity. -
rawJson
Returns the full arguments as a JSON string.- Returns:
- the JSON string
-
decode
Decodes the full arguments into the given type using the configured serde.- Type Parameters:
T- the target type- Parameters:
targetType- the target type- Returns:
- the decoded value
- Throws:
IllegalStateException- if no serde is configuredInvalidArgumentException- if the arguments cannot be decoded intotargetType; the dispatcher maps this to an invalid-params error rather than an internal failure
-
decode
Decodes the full arguments into the given class using the configured serde.- Type Parameters:
T- the target type- Parameters:
targetClass- the target class- Returns:
- the decoded value
- Throws:
IllegalStateException- if no serde is configured
-