Class ArraySchema

java.lang.Object
jsonvalues.spec.ArraySchema

public final class ArraySchema extends Object
A class representing the schema for arrays in a JSON structure. It allows setting constraints such as minimum and maximum number of items and uniqueness of items in the array.
  • Method Details

    • withMinSize

      public static ArraySchema withMinSize(int minItems)
      Creates an ArraySchema with a minimum size constraint.
      Parameters:
      minItems - The minimum number of items allowed in the array (must be >= 0).
      Returns:
      An ArraySchema instance with the specified minimum size constraint.
      Throws:
      IllegalArgumentException - if minItems is less than 0.
    • withMaxSize

      public static ArraySchema withMaxSize(int maxItems)
      Creates an ArraySchema with a maximum size constraint.
      Parameters:
      maxItems - The maximum number of items allowed in the array (must be >= 0).
      Returns:
      An ArraySchema instance with the specified maximum size constraint.
      Throws:
      IllegalArgumentException - if maxItems is less than 0.
    • sizeBetween

      public static ArraySchema sizeBetween(int minItems, int maxItems)
      Creates an ArraySchema with both minimum and maximum size constraints.
      Parameters:
      minItems - The minimum number of items allowed in the array (must be >= 0).
      maxItems - The maximum number of items allowed in the array (must be >= 0).
      Returns:
      An ArraySchema instance with the specified minimum and maximum size constraints.
      Throws:
      IllegalArgumentException - if minItems or maxItems is less than 0.
    • setUniqueItems

      public ArraySchema setUniqueItems()
      Sets the uniqueItems constraint for the array.
      Returns:
      The current ArraySchema instance with the uniqueItems constraint set to true.