Package io.github.wasabithumb.jtoml.key
Interface TomlKey
- All Superinterfaces:
Collection<String>,Comparable<TomlKey>,Iterable<String>
Represents a parsed TOML key by parts
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault intdefault @NotNull Stringget(int index) Gets the Nth part of this key.static @NotNull TomlKeyReturns a TOML key that represents a concatenation of the parts of each provided key.static <S extends CharSequence>
@NotNull TomlKeyliteral(@NotNull S @NotNull ... parts) Wraps a pre-parsed TOML key (by parts) into aTomlKeyobject.static @NotNull TomlKeyparse(@NotNull CharSequence key) Parses a string representation of a TOML key.intsize()Provides the number of parts in this key.default @NotNull TomlKeyslice(int fromIndex, int toIndex) stream()@NotNull StringtoString()Serializes the key represented by this object into a TOML-compatible form, escaping as necessary.Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, toArray, toArray, toArray
-
Method Details
-
parse
@Contract("_ -> new") @NotNull static @NotNull TomlKey parse(@NotNull @NotNull CharSequence key) throws IllegalArgumentException Parses a string representation of a TOML key. Extraneous whitespace is NOT allowed.Example
TomlKey.parse("'foo.bar'.\"\\U0001F60E\"") .toString(); // "foo.bar"."😎"- Throws:
IllegalArgumentException- Key is empty, has empty parts, has an illegally placed opening quotation mark/single quote, has a missing closing quotation mark/single quote, has an unescaped special character between opening and closing quotation marks, or has a single quote between opening and closing single quotes
-
join
@NotNull static @NotNull TomlKey join(@NotNull @NotNull TomlKey first, @NotNull @NotNull TomlKey @NotNull ... additional) Returns a TOML key that represents a concatenation of the parts of each provided key. If only 1 key is provided (additionalis empty), the first key (first) is always returned as-is. Otherwise, a new key is created. -
literal
@SafeVarargs @Experimental @Contract("_ -> new") @NotNull static <S extends CharSequence> @NotNull TomlKey literal(@NotNull @NotNull S @NotNull ... parts) Wraps a pre-parsed TOML key (by parts) into aTomlKeyobject. No parsing is performed.- See Also:
-
size
int size()Provides the number of parts in this key. A valid key is expected to have at least 1 part. The TomlKey that serializes to""would have 1 part with a length of 0.- Specified by:
sizein interfaceCollection<String>
-
get
Gets the Nth part of this key. Depending on the key implementation, this may be less efficient thanstream()/Collection.iterator().- Throws:
IndexOutOfBoundsException
-
stream
- Specified by:
streamin interfaceCollection<String>
-
slice
-
toString
Serializes the key represented by this object into a TOML-compatible form, escaping as necessary. Escaping will always be done with basic (double quote) strings, literal (single quote) strings are never chosen.Example
TomlKey.literal("lorem ipsum", "dolor", "\"sit amet\"") .toString() // "lorem ipsum".dolor."\"sit amet\"" -
compareTo
- Specified by:
compareToin interfaceComparable<TomlKey>
-