Record Class TomlTable
java.lang.Object
java.lang.Record
be.imgn.toml.TomlTable
- Record Components:
entries- the entries, which keep their iteration order; the map is copied
- All Implemented Interfaces:
TomlValue
A TOML table: keys mapped to values, in the order the keys were given or appeared in the document.
Besides entries(), a table looks its values up by a TOML key, which can be dotted and quoted as in a
document. get("server.port") is the value of the key port in the table server, and
get("site.\"example.com\"") the value of the key example.com in the table site. The typed
getters, such as getString(String), also check the type of the value.
Two tables are equal when they have the same entries, whatever their order.
- Since:
- 0.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilds aTomlTable, keeping its entries in the order they are put. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TomlTable.Builderbuilder()Returns a builder of tables, which keeps the entries in the order they are put.entries()Returns the value of theentriesrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of a key.Returns the array that is the value of a key.booleangetBoolean(String key) Returns the boolean that is the value of a key.doubleReturns the float that is the value of a key.intReturns the integer that is the value of a key, as anint.getLocalDate(String key) Returns the local date that is the value of a key.getLocalDateTime(String key) Returns the local date-time that is the value of a key.getLocalTime(String key) Returns the local time that is the value of a key.longReturns the integer that is the value of a key.getOffsetDateTime(String key) Returns the offset date-time that is the value of a key.Returns the string that is the value of a key.Returns the table that is the value of a key.final inthashCode()Returns a hash code value for this object.Returns a builder that starts with the entries of this table, in their order.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
TomlTable
Creates a table.- Throws:
NullPointerException- ifentriesis null, or contains a null key or valueIllegalArgumentException- if a key contains an unpaired surrogate
-
-
Method Details
-
builder
Returns a builder of tables, which keeps the entries in the order they are put.- Returns:
- a new builder
-
toBuilder
Returns a builder that starts with the entries of this table, in their order. The builder does not change this table.- Returns:
- a new builder
-
get
Returns the value of a key.- Parameters:
key- a key, which can be dotted and quoted as in a document- Returns:
- the value of
key, or empty if this table has none - Throws:
NullPointerException- ifkeyis nullIllegalArgumentException- ifkeyis not a valid TOML key
-
getTable
Returns the table that is the value of a key.- Parameters:
key- a key, which can be dotted and quoted as in a document- Returns:
- the value of
key - Throws:
NullPointerException- ifkeyis nullIllegalArgumentException- ifkeyis not a valid TOML keyNoSuchElementException- if this table has no value forkeyClassCastException- if the value ofkeyis not a table
-
getArray
Returns the array that is the value of a key.- Parameters:
key- a key, which can be dotted and quoted as in a document- Returns:
- the value of
key - Throws:
NullPointerException- ifkeyis nullIllegalArgumentException- ifkeyis not a valid TOML keyNoSuchElementException- if this table has no value forkeyClassCastException- if the value ofkeyis not an array
-
getString
Returns the string that is the value of a key.- Parameters:
key- a key, which can be dotted and quoted as in a document- Returns:
- the value of
key - Throws:
NullPointerException- ifkeyis nullIllegalArgumentException- ifkeyis not a valid TOML keyNoSuchElementException- if this table has no value forkeyClassCastException- if the value ofkeyis not a string
-
getLong
Returns the integer that is the value of a key.- Parameters:
key- a key, which can be dotted and quoted as in a document- Returns:
- the value of
key - Throws:
NullPointerException- ifkeyis nullIllegalArgumentException- ifkeyis not a valid TOML keyNoSuchElementException- if this table has no value forkeyClassCastException- if the value ofkeyis not an integer
-
getInt
Returns the integer that is the value of a key, as anint.- Parameters:
key- a key, which can be dotted and quoted as in a document- Returns:
- the value of
key - Throws:
NullPointerException- ifkeyis nullIllegalArgumentException- ifkeyis not a valid TOML keyNoSuchElementException- if this table has no value forkeyClassCastException- if the value ofkeyis not an integerArithmeticException- if the value ofkeyis out of the range ofint
-
getDouble
Returns the float that is the value of a key.- Parameters:
key- a key, which can be dotted and quoted as in a document- Returns:
- the value of
key - Throws:
NullPointerException- ifkeyis nullIllegalArgumentException- ifkeyis not a valid TOML keyNoSuchElementException- if this table has no value forkeyClassCastException- if the value ofkeyis not a float
-
getBoolean
Returns the boolean that is the value of a key.- Parameters:
key- a key, which can be dotted and quoted as in a document- Returns:
- the value of
key - Throws:
NullPointerException- ifkeyis nullIllegalArgumentException- ifkeyis not a valid TOML keyNoSuchElementException- if this table has no value forkeyClassCastException- if the value ofkeyis not a boolean
-
getOffsetDateTime
Returns the offset date-time that is the value of a key.- Parameters:
key- a key, which can be dotted and quoted as in a document- Returns:
- the value of
key - Throws:
NullPointerException- ifkeyis nullIllegalArgumentException- ifkeyis not a valid TOML keyNoSuchElementException- if this table has no value forkeyClassCastException- if the value ofkeyis not an offset date-time
-
getLocalDateTime
Returns the local date-time that is the value of a key.- Parameters:
key- a key, which can be dotted and quoted as in a document- Returns:
- the value of
key - Throws:
NullPointerException- ifkeyis nullIllegalArgumentException- ifkeyis not a valid TOML keyNoSuchElementException- if this table has no value forkeyClassCastException- if the value ofkeyis not a local date-time
-
getLocalDate
Returns the local date that is the value of a key.- Parameters:
key- a key, which can be dotted and quoted as in a document- Returns:
- the value of
key - Throws:
NullPointerException- ifkeyis nullIllegalArgumentException- ifkeyis not a valid TOML keyNoSuchElementException- if this table has no value forkeyClassCastException- if the value ofkeyis not a local date
-
getLocalTime
Returns the local time that is the value of a key.- Parameters:
key- a key, which can be dotted and quoted as in a document- Returns:
- the value of
key - Throws:
NullPointerException- ifkeyis nullIllegalArgumentException- ifkeyis not a valid TOML keyNoSuchElementException- if this table has no value forkeyClassCastException- if the value ofkeyis not a local time
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
entries
-