Interface ListBuilder
Appends the entries of one LIST instance.
The verb matches the list's element type: a list of primitives takes addString(String) and its
siblings, a list of structs takes addStruct(Consumer), and a list of lists or of maps takes
addList(Consumer) / addMap(Consumer). Using a verb the element type does not fit throws at the call.
row.setList("phones", phones -> phones
.addString("+49 30 1234567")
.addString("+1 415 5550100"));
Every entry the filler appends is one element of the list, in the order appended. A filler that appends nothing writes an empty list, which is distinct from the absent list that leaving the field unset writes.
The builder is valid only inside the lambda it was passed to. Retaining one and using it
afterwards throws IllegalStateException rather than appending to a later list.
This API is Experimental: the shape may change in future releases.
-
Method Summary
Modifier and TypeMethodDescriptionaddBinary(byte[] value) Appends aBYTE_ARRAYorFIXED_LEN_BYTE_ARRAYentry.addBoolean(boolean value) Appends aBOOLEANentry.Appends aDATEentry.addDecimal(BigDecimal value) Appends aDECIMALentry.addDouble(double value) Appends aDOUBLEentry.addFloat(float value) Appends aFLOATentry.addInt(int value) Appends anINT32entry.addInterval(PqInterval value) Appends anINTERVALentry.addList(Consumer<ListBuilder> filler) Appends a nested list entry, populating it throughfiller.addLocalTimestamp(LocalDateTime value) Appends a local-wall-clockTIMESTAMPentry.addLong(long value) Appends anINT64entry.addMap(Consumer<MapBuilder> filler) Appends a map entry, populating it throughfiller.addNull()Appends a null entry, which occupies a position in the list — distinct from the list itself being absent, and from the list being empty.Appends aSTRING,ENUMorJSONentry from its UTF-8 bytes.addStruct(Consumer<StructBuilder> filler) Appends a struct entry, populating it throughfiller.Appends aTIMEentry.addTimestamp(Instant value) Appends a UTC-adjustedTIMESTAMPentry.Appends aUUIDentry.
-
Method Details
-
addInt
Appends anINT32entry.- Parameters:
value- the value- Returns:
- this builder, for chaining
- Throws:
IllegalArgumentException- if the element is not anINT32leaf, or the value is out of range for the element's annotationIllegalStateException- if this builder's scope has ended- See Also:
-
addLong
-
addFloat
-
addDouble
-
addBoolean
-
addString
Appends aSTRING,ENUMorJSONentry from its UTF-8 bytes. Anullvalue appends a null entry.- See Also:
-
addBinary
Appends aBYTE_ARRAYorFIXED_LEN_BYTE_ARRAYentry. Anullvalue appends a null entry.- See Also:
-
addDate
Appends aDATEentry. Anullvalue appends a null entry.- See Also:
-
addTime
Appends aTIMEentry. Anullvalue appends a null entry.- See Also:
-
addTimestamp
Appends a UTC-adjustedTIMESTAMPentry. Anullvalue appends a null entry.- See Also:
-
addLocalTimestamp
Appends a local-wall-clockTIMESTAMPentry. Anullvalue appends a null entry.- See Also:
-
addDecimal
Appends aDECIMALentry. Anullvalue appends a null entry.- See Also:
-
addUuid
-
addInterval
Appends anINTERVALentry. Anullvalue appends a null entry.- See Also:
-
addNull
ListBuilder addNull()Appends a null entry, which occupies a position in the list — distinct from the list itself being absent, and from the list being empty.- Returns:
- this builder, for chaining
- Throws:
IllegalArgumentException- if the list's element isREQUIREDIllegalStateException- if this builder's scope has ended
-
addStruct
Appends a struct entry, populating it throughfiller.- Parameters:
filler- populates the entry- Returns:
- this builder, for chaining
- Throws:
IllegalArgumentException- if the list's element is not a struct groupIllegalStateException- if this builder's scope has ended
-
addList
Appends a nested list entry, populating it throughfiller.- Parameters:
filler- appends the nested list's entries- Returns:
- this builder, for chaining
- Throws:
IllegalArgumentException- if the list's element is not aLISTgroupIllegalStateException- if this builder's scope has ended
-
addMap
Appends a map entry, populating it throughfiller.- Parameters:
filler- appends the map's entries- Returns:
- this builder, for chaining
- Throws:
IllegalArgumentException- if the list's element is not aMAPgroupIllegalStateException- if this builder's scope has ended
-