Class Param<T>

java.lang.Object
com.github.copilot.tool.Param<T>
Type Parameters:
T - the Java type of the parameter value

@CopilotExperimental public final class Param<T> extends Object
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 Details

    • of

      public static <T> Param<T> of(Class<T> type, String name, String description)
      Creates a required parameter with no default value.
      Type Parameters:
      T - the parameter type
      Parameters:
      type - the Java class of the parameter
      name - the wire name sent to the model (must not be blank)
      description - a human-readable description (must not be blank)
      Returns:
      a new Param instance
      Throws:
      NullPointerException - if type is null
      IllegalArgumentException - if name or description is 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 parameter
      name - 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 required
      defaultValue - the default value as a string, or null/empty for none
      Returns:
      a new Param instance
      Throws:
      NullPointerException - if type is null
      IllegalArgumentException - if validation fails
    • name

      public Param<T> name(String name)
      Returns a copy with a different name.
      Parameters:
      name - the new parameter name
      Returns:
      a new Param with the updated name
    • description

      public Param<T> description(String description)
      Returns a copy with a different description.
      Parameters:
      description - the new description
      Returns:
      a new Param with the updated description
    • required

      public Param<T> required(boolean required)
      Returns a copy with a different required flag.
      Parameters:
      required - whether the parameter is required
      Returns:
      a new Param with the updated required flag
    • defaultValue

      public Param<T> defaultValue(String 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 Param with the default applied and required set to false
    • type

      public Class<T> type()
      Returns the Java type of this parameter.
    • name

      public String name()
      Returns the wire name of this parameter.
    • description

      public String description()
      Returns the human-readable description.
    • required

      public boolean required()
      Returns whether this parameter is required.
    • defaultValue

      public String defaultValue()
      Returns the default value string, or empty if none.
    • hasDefaultValue

      public boolean hasDefaultValue()
      Returns true if a non-empty default value is set.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object