Class JsonSchemaProperty

java.lang.Object
dev.langchain4j.agent.tool.JsonSchemaProperty

public class JsonSchemaProperty extends Object
Represents a property in a JSON schema.
  • Field Details

    • STRING

      public static final JsonSchemaProperty STRING
      A property with key "type" and value "string".
    • INTEGER

      public static final JsonSchemaProperty INTEGER
      A property with key "type" and value "integer".
    • NUMBER

      public static final JsonSchemaProperty NUMBER
      A property with key "type" and value "number".
    • OBJECT

      public static final JsonSchemaProperty OBJECT
      A property with key "type" and value "object".
    • ARRAY

      public static final JsonSchemaProperty ARRAY
      A property with key "type" and value "array".
    • BOOLEAN

      public static final JsonSchemaProperty BOOLEAN
      A property with key "type" and value "boolean".
    • NULL

      public static final JsonSchemaProperty NULL
      A property with key "type" and value "null".
  • Constructor Details

    • JsonSchemaProperty

      public JsonSchemaProperty(String key, Object value)
      Construct a property with key and value.
      Parameters:
      key - the key.
      value - the value.
  • Method Details

    • key

      public String key()
      Get the key.
      Returns:
      the key.
    • value

      public Object value()
      Get the value.
      Returns:
      the value.
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object
    • from

      public static JsonSchemaProperty from(String key, Object value)
      Construct a property with key and value.

      Equivalent to new JsonSchemaProperty(key, value).

      Parameters:
      key - the key.
      value - the value.
      Returns:
      a property with key and value.
    • property

      public static JsonSchemaProperty property(String key, Object value)
      Construct a property with key and value.

      Equivalent to new JsonSchemaProperty(key, value).

      Parameters:
      key - the key.
      value - the value.
      Returns:
      a property with key and value.
    • type

      public static JsonSchemaProperty type(String value)
      Construct a property with key "type" and value.

      Equivalent to new JsonSchemaProperty("type", value).

      Parameters:
      value - the value.
      Returns:
      a property with key and value.
    • description

      public static JsonSchemaProperty description(String value)
      Construct a property with key "description" and value.

      Equivalent to new JsonSchemaProperty("description", value).

      Parameters:
      value - the value.
      Returns:
      a property with key and value.
    • enums

      public static JsonSchemaProperty enums(String... enumValues)
      Construct a property with key "enum" and value enumValues.
      Parameters:
      enumValues - enum values as strings. For example: enums("CELSIUS", "FAHRENHEIT")
      Returns:
      a property with key "enum" and value enumValues
    • enums

      public static JsonSchemaProperty enums(Object... enumValues)
      Construct a property with key "enum" and value enumValues.

      Verifies that each value is a java class.

      Parameters:
      enumValues - enum values. For example: enums(TemperatureUnit.CELSIUS, TemperatureUnit.FAHRENHEIT)
      Returns:
      a property with key "enum" and value enumValues
    • enums

      public static JsonSchemaProperty enums(Class<?> enumClass)
      Construct a property with key "enum" and all enum values taken from enumClass.
      Parameters:
      enumClass - enum class. For example: enums(TemperatureUnit.class)
      Returns:
      a property with key "enum" and values taken from enumClass
    • items

      public static JsonSchemaProperty items(JsonSchemaProperty type)
      Wraps the given type in a property with key "items".
      Parameters:
      type - the type
      Returns:
      a property with key "items" and value type.
    • objectItems

      public static JsonSchemaProperty objectItems(JsonSchemaProperty type)