Class Param<T>
java.lang.Object
com.github.copilot.tool.Param<T>
- Type Parameters:
T- the Java type of the parameter value
Runtime parameter metadata for lambda-defined tools.
Each Param instance describes a single parameter that a tool accepts,
including its Java type, wire name, description, whether it is required, and
an optional default value. Instances are immutable; fluent mutators return
new copies.
Example Usage
Param<String> query = Param.of(String.class, "query", "Search query text");
Param<Integer> limit = Param.of(Integer.class, "limit", "Max results", false, "10");
- Since:
- 1.0.6
-
Method Summary
Modifier and TypeMethodDescriptionReturns the default value string, or empty if none.defaultValue(String defaultValue) Returns an optional copy with the given default value.Returns the human-readable description.description(String description) Returns a copy with a different description.booleanbooleanReturnstrueif a non-empty default value is set.inthashCode()name()Returns the wire name of this parameter.Returns a copy with a different name.static <T> Param<T> Creates a required parameter with no default value.static <T> Param<T> Creates a parameter with explicit required/default settings.booleanrequired()Returns whether this parameter is required.required(boolean required) Returns a copy with a different required flag.toString()type()Returns the Java type of this parameter.
-
Method Details
-
of
Creates a required parameter with no default value.- Type Parameters:
T- the parameter type- Parameters:
type- the Java class of the parametername- the wire name sent to the model (must not be blank)description- a human-readable description (must not be blank)- Returns:
- a new
Paraminstance - Throws:
NullPointerException- iftypeis nullIllegalArgumentException- ifnameordescriptionis blank
-
of
public static <T> Param<T> of(Class<T> type, String name, String description, boolean required, String defaultValue) Creates a parameter with explicit required/default settings.- Type Parameters:
T- the parameter type- Parameters:
type- the Java class of the parametername- the wire name sent to the model (must not be blank)description- a human-readable description (must not be blank)required- whether the parameter is requireddefaultValue- the default value as a string, ornull/empty for none- Returns:
- a new
Paraminstance - Throws:
NullPointerException- iftypeis nullIllegalArgumentException- if validation fails
-
name
-
description
-
required
-
defaultValue
Returns an optional copy with the given default value. Setting a default implicitly makes the parameter optional (required=false).- Parameters:
defaultValue- the default value as a string- Returns:
- a new
Paramwith the default applied and required set to false
-
type
-
name
Returns the wire name of this parameter. -
description
Returns the human-readable description. -
required
public boolean required()Returns whether this parameter is required. -
defaultValue
Returns the default value string, or empty if none. -
hasDefaultValue
public boolean hasDefaultValue()Returnstrueif a non-empty default value is set. -
equals
-
hashCode
-
toString
-