Package jsonvalues.spec
Class ArraySchema
java.lang.Object
jsonvalues.spec.ArraySchema
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 Summary
Modifier and TypeMethodDescriptionSets the uniqueItems constraint for the array.static ArraySchema
sizeBetween
(int minItems, int maxItems) Creates an ArraySchema with both minimum and maximum size constraints.static ArraySchema
withMaxSize
(int maxItems) Creates an ArraySchema with a maximum size constraint.static ArraySchema
withMinSize
(int minItems) Creates an ArraySchema with a minimum size constraint.
-
Method Details
-
withMinSize
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
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
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
Sets the uniqueItems constraint for the array.- Returns:
- The current ArraySchema instance with the uniqueItems constraint set to true.
-