Skip to main content

Reading Entries Basics

Configuration files can contain entries for anything from primitive types up to complex hierarchies of POJOs consisting of Maps, Collections, and/or beans.

Entries are accessed via the Config.get(String) method which returns the following bean:

Entry get() isNotEmpty() isPresent() orElse(String) orElseGet(Supplier) as(Class) as(Parser,Class) as(Parser,Type,Type...) as(Type,Type...) asBoolean() asBytes() asDouble() asFloat() asInteger() asList() asList(Parser) asLong() asMap() asMap(Parser) asString() asStringArray() getComment() getKey() getModifiers() getPreLines() getValue()

The most common case for configuration values are primitives.

# A string
key1 = foo

# A boolean
key2 = true

# An integer
key3 = 123

# A long
key4 = 10000000000

# Doubles
key5 = 6.67e−11
key6 = Infinity

On integers and longs, "K", "M", and "G" can be used to identify kilo, mega, and giga.

key1 = 100K  # Same as 1024000
key2 = 100M # Same as 104857600

Numbers can also use hexadecimal and octal notation:

hex1 = 0x12FE
hex2 = 0X12FE
octal1 = 01234

Strings with newlines are treated as multi-line values that get broken into separate lines:

key1 = This is a particularly long sentence that we want to split
onto separate lines.

Typically, multi-line values are started on the next line for clarity like so:

key1 =
This is a particularly long sentence that we want to split
onto separate lines.