Class Schema.Builder

java.lang.Object
com.google.genai.types.Schema.Builder
Enclosing class:
Schema

public abstract static class Schema.Builder extends Object
Builder for Schema.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • anyOf

      public abstract Schema.Builder anyOf(List<Schema> anyOf)
      Setter for anyOf.

      anyOf: Optional. The instance must be valid against any (one or more) of the subschemas listed in `any_of`.

    • anyOf

      @CanIgnoreReturnValue public Schema.Builder anyOf(Schema... anyOf)
      Setter for anyOf.

      anyOf: Optional. The instance must be valid against any (one or more) of the subschemas listed in `any_of`.

    • anyOf

      @CanIgnoreReturnValue public Schema.Builder anyOf(Schema.Builder... anyOfBuilders)
      Setter for anyOf builder.

      anyOf: Optional. The instance must be valid against any (one or more) of the subschemas listed in `any_of`.

    • clearAnyOf

      @CanIgnoreReturnValue public Schema.Builder clearAnyOf()
      Clears the value of anyOf field.
    • default_

      public abstract Schema.Builder default_(Object default_)
      Setter for default_.

      default_: Optional. Default value to use if the field is not specified.

    • clearDefault_

      @CanIgnoreReturnValue public Schema.Builder clearDefault_()
      Clears the value of default_ field.
    • description

      public abstract Schema.Builder description(String description)
      Setter for description.

      description: Optional. Description of the schema.

    • clearDescription

      @CanIgnoreReturnValue public Schema.Builder clearDescription()
      Clears the value of description field.
    • enum_

      public abstract Schema.Builder enum_(List<String> enum_)
      Setter for enum_.

      enum_: Optional. Possible values of the field. This field can be used to restrict a value to a fixed set of values. To mark a field as an enum, set `format` to `enum` and provide the list of possible values in `enum`. For example: 1. To define directions: `{type:STRING, format:enum, enum:["EAST", "NORTH", "SOUTH", "WEST"]}` 2. To define apartment numbers: `{type:INTEGER, format:enum, enum:["101", "201", "301"]}`

    • enum_

      @CanIgnoreReturnValue public Schema.Builder enum_(String... enum_)
      Setter for enum_.

      enum_: Optional. Possible values of the field. This field can be used to restrict a value to a fixed set of values. To mark a field as an enum, set `format` to `enum` and provide the list of possible values in `enum`. For example: 1. To define directions: `{type:STRING, format:enum, enum:["EAST", "NORTH", "SOUTH", "WEST"]}` 2. To define apartment numbers: `{type:INTEGER, format:enum, enum:["101", "201", "301"]}`

    • clearEnum_

      @CanIgnoreReturnValue public Schema.Builder clearEnum_()
      Clears the value of enum_ field.
    • example

      public abstract Schema.Builder example(Object example)
      Setter for example.

      example: Optional. Example of an instance of this schema.

    • clearExample

      @CanIgnoreReturnValue public Schema.Builder clearExample()
      Clears the value of example field.
    • format

      public abstract Schema.Builder format(String format)
      Setter for format.

      format: Optional. The format of the data. For `NUMBER` type, format can be `float` or `double`. For `INTEGER` type, format can be `int32` or `int64`. For `STRING` type, format can be `email`, `byte`, `date`, `date-time`, `password`, and other formats to further refine the data type.

    • clearFormat

      @CanIgnoreReturnValue public Schema.Builder clearFormat()
      Clears the value of format field.
    • items

      public abstract Schema.Builder items(Schema items)
      Setter for items.

      items: Optional. If type is `ARRAY`, `items` specifies the schema of elements in the array.

    • items

      @CanIgnoreReturnValue public Schema.Builder items(Schema.Builder itemsBuilder)
      Setter for items builder.

      items: Optional. If type is `ARRAY`, `items` specifies the schema of elements in the array.

    • clearItems

      @CanIgnoreReturnValue public Schema.Builder clearItems()
      Clears the value of items field.
    • maxItems

      public abstract Schema.Builder maxItems(Long maxItems)
      Setter for maxItems.

      maxItems: Optional. If type is `ARRAY`, `max_items` specifies the maximum number of items in an array.

    • clearMaxItems

      @CanIgnoreReturnValue public Schema.Builder clearMaxItems()
      Clears the value of maxItems field.
    • maxLength

      public abstract Schema.Builder maxLength(Long maxLength)
      Setter for maxLength.

      maxLength: Optional. If type is `STRING`, `max_length` specifies the maximum length of the string.

    • clearMaxLength

      @CanIgnoreReturnValue public Schema.Builder clearMaxLength()
      Clears the value of maxLength field.
    • maxProperties

      public abstract Schema.Builder maxProperties(Long maxProperties)
      Setter for maxProperties.

      maxProperties: Optional. If type is `OBJECT`, `max_properties` specifies the maximum number of properties that can be provided.

    • clearMaxProperties

      @CanIgnoreReturnValue public Schema.Builder clearMaxProperties()
      Clears the value of maxProperties field.
    • maximum

      public abstract Schema.Builder maximum(Double maximum)
      Setter for maximum.

      maximum: Optional. If type is `INTEGER` or `NUMBER`, `maximum` specifies the maximum allowed value.

    • clearMaximum

      @CanIgnoreReturnValue public Schema.Builder clearMaximum()
      Clears the value of maximum field.
    • minItems

      public abstract Schema.Builder minItems(Long minItems)
      Setter for minItems.

      minItems: Optional. If type is `ARRAY`, `min_items` specifies the minimum number of items in an array.

    • clearMinItems

      @CanIgnoreReturnValue public Schema.Builder clearMinItems()
      Clears the value of minItems field.
    • minLength

      public abstract Schema.Builder minLength(Long minLength)
      Setter for minLength.

      minLength: Optional. If type is `STRING`, `min_length` specifies the minimum length of the string.

    • clearMinLength

      @CanIgnoreReturnValue public Schema.Builder clearMinLength()
      Clears the value of minLength field.
    • minProperties

      public abstract Schema.Builder minProperties(Long minProperties)
      Setter for minProperties.

      minProperties: Optional. If type is `OBJECT`, `min_properties` specifies the minimum number of properties that can be provided.

    • clearMinProperties

      @CanIgnoreReturnValue public Schema.Builder clearMinProperties()
      Clears the value of minProperties field.
    • minimum

      public abstract Schema.Builder minimum(Double minimum)
      Setter for minimum.

      minimum: Optional. If type is `INTEGER` or `NUMBER`, `minimum` specifies the minimum allowed value.

    • clearMinimum

      @CanIgnoreReturnValue public Schema.Builder clearMinimum()
      Clears the value of minimum field.
    • nullable

      public abstract Schema.Builder nullable(boolean nullable)
      Setter for nullable.

      nullable: Optional. Indicates if the value of this field can be null.

    • clearNullable

      @CanIgnoreReturnValue public Schema.Builder clearNullable()
      Clears the value of nullable field.
    • pattern

      public abstract Schema.Builder pattern(String pattern)
      Setter for pattern.

      pattern: Optional. If type is `STRING`, `pattern` specifies a regular expression that the string must match.

    • clearPattern

      @CanIgnoreReturnValue public Schema.Builder clearPattern()
      Clears the value of pattern field.
    • properties

      public abstract Schema.Builder properties(Map<String,Schema> properties)
      Setter for properties.

      properties: Optional. If type is `OBJECT`, `properties` is a map of property names to schema definitions for each property of the object.

    • clearProperties

      @CanIgnoreReturnValue public Schema.Builder clearProperties()
      Clears the value of properties field.
    • propertyOrdering

      public abstract Schema.Builder propertyOrdering(List<String> propertyOrdering)
      Setter for propertyOrdering.

      propertyOrdering: Optional. Order of properties displayed or used where order matters. This is not a standard field in OpenAPI specification, but can be used to control the order of properties.

    • propertyOrdering

      @CanIgnoreReturnValue public Schema.Builder propertyOrdering(String... propertyOrdering)
      Setter for propertyOrdering.

      propertyOrdering: Optional. Order of properties displayed or used where order matters. This is not a standard field in OpenAPI specification, but can be used to control the order of properties.

    • clearPropertyOrdering

      @CanIgnoreReturnValue public Schema.Builder clearPropertyOrdering()
      Clears the value of propertyOrdering field.
    • required

      public abstract Schema.Builder required(List<String> required)
      Setter for required.

      required: Optional. If type is `OBJECT`, `required` lists the names of properties that must be present.

    • required

      @CanIgnoreReturnValue public Schema.Builder required(String... required)
      Setter for required.

      required: Optional. If type is `OBJECT`, `required` lists the names of properties that must be present.

    • clearRequired

      @CanIgnoreReturnValue public Schema.Builder clearRequired()
      Clears the value of required field.
    • title

      public abstract Schema.Builder title(String title)
      Setter for title.

      title: Optional. Title for the schema.

    • clearTitle

      @CanIgnoreReturnValue public Schema.Builder clearTitle()
      Clears the value of title field.
    • type

      public abstract Schema.Builder type(Type type)
      Setter for type.

      type: Optional. Data type of the schema field.

    • clearType

      @CanIgnoreReturnValue public Schema.Builder clearType()
      Clears the value of type field.
    • type

      @CanIgnoreReturnValue public Schema.Builder type(Type.Known knownType)
      Setter for type given a known enum.

      type: Optional. Data type of the schema field.

    • type

      @CanIgnoreReturnValue public Schema.Builder type(String type)
      Setter for type given a string.

      type: Optional. Data type of the schema field.

    • build

      public abstract Schema build()