Class Entry
Config file.- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescription<T> Optional<T>Returns this entry converted to the specified type.<T> Optional<T>Returns this entry converted to the specified value.<T> Optional<T>Returns this entry converted to the specified type.<T> Optional<T>Same asas(Type, Type...)but specifies the parser to use to parse the entry.Returns this entry as a parsed boolean.Optional<byte[]>asBytes()Returns this entry as a byte array.asDouble()Returns this entry as a double.asFloat()Returns this entry as a float.Returns this entry as an integer.asList()Returns this entry as a parsed list.Returns this entry as a parsed list.asLong()Returns this entry as a long.asMap()Returns this entry as a parsed map.Returns this entry as a parsed map.asString()Returns this entry as a string.Returns this entry as a string array.get()Returns this entry as a string.Returns the same-line comment of this entry.getKey()Returns the name of this entry.Returns the modifiers for this entry.Returns the pre-lines of this entry.getValue()Returns the raw value of this entry.booleanReturnstrue if this entry exists in the config and is not empty.booleanReturnstrue if this entry exists in the config.Returns this entry converted to the specified type or returns the default value.Returns this entry converted to the specified type or returns the default value.toString()Returns this entry as a string.
- 
Constructor Details- 
EntryConstructor.- Parameters:
- config- The config that this entry belongs to.
- configMap- The map that this belongs to.
- sectionName- The section name of this entry.
- entryName- The name of this entry.
 
 
- 
- 
Method Details- 
isPresentReturnstrue if this entry exists in the config.- Returns:
- true if this entry exists in the config.
 
- 
isNotEmptyReturnstrue if this entry exists in the config and is not empty.- Returns:
- true if this entry exists in the config and is not empty.
 
- 
getReturns this entry as a string.- Returns:
- true if this entry exists in the config and is not empty.
- Throws:
- NullPointerException- if value was- null .
 
- 
orElseReturns this entry converted to the specified type or returns the default value.This is equivalent to calling as( but is simpler and avoids the creation of andef .getClass()).orElse(def )Optionalobject.- Parameters:
- def- The default value to return if value does not exist.
- Returns:
- This entry converted to the specified type or returns the default value.
 
- 
orElseGetReturns this entry converted to the specified type or returns the default value.This is equivalent to calling as( but is simpler and avoids the creation of andef .getClass()).orElse(def )Optionalobject.- Parameters:
- def- The default value to return if value does not exist.
- Returns:
- This entry converted to the specified type or returns the default value.
 
- 
asReturns this entry converted to the specified type.- Type Parameters:
- T- The type to convert the value to.
- Parameters:
- type- The type to convert the value to.
- Returns:
- This entry converted to the specified type.
 
- 
asReturns this entry converted to the specified value.The type can be a simple type (e.g. beans, strings, numbers) or parameterized type (collections/maps). Examples:Config config = Config.create ().name("MyConfig.cfg" ).build();// Parse into a linked-list of strings. Listlist =config .get("MySection/myListOfStrings" ).to(LinkedList.class , String.class );// Parse into a linked-list of beans. Listlist =config .get("MySection/myListOfBeans" ).to(LinkedList.class , MyBean.class );// Parse into a linked-list of linked-lists of strings. Listlist =config .get("MySection/my2dListOfStrings" ).to(LinkedList.class , LinkedList.class , String.class );// Parse into a map of string keys/values. Mapmap =config .get("MySection/myMap" ).to(TreeMap.class , String.class , String.class );// Parse into a map containing string keys and values of lists containing beans. Mapmap =config .get("MySection/myMapOfListsOfBeans" ).to(TreeMap.class , String.class , List.class , MyBean.class );Collection classes are assumed to be followed by zero or one objects indicating the element type.Map classes are assumed to be followed by zero or two meta objects indicating the key and value types.The array can be arbitrarily long to indicate arbitrarily complex data structures. Notes:- 
      Use the as(Class)method instead if you don't need a parameterized map/collection.
 - Type Parameters:
- T- The object type to create.
- Parameters:
- type- The object type to create.
 Can be any of the following:- ClassMeta,- Class,- ParameterizedType,- GenericArrayType
- args- The type arguments of the class if it's a collection or map.
 Can be any of the following:- ClassMeta,- Class,- ParameterizedType,- GenericArrayType
 Ignored if the main type is not a map or collection.
- Returns:
- The value, or Optional.empty()if the section or key does not exist.
 
- 
      Use the 
- 
asSame asas(Type, Type...)but specifies the parser to use to parse the entry.- Type Parameters:
- T- The object type to create.
- Parameters:
- parser- The parser to use to parse the entry.
- type- The object type to create.
 Can be any of the following:- ClassMeta,- Class,- ParameterizedType,- GenericArrayType
- args- The type arguments of the class if it's a collection or map.
 Can be any of the following:- ClassMeta,- Class,- ParameterizedType,- GenericArrayType
 Ignored if the main type is not a map or collection.
- Returns:
- The value, or Optional.empty()if the section or key does not exist.
 
- 
asReturns this entry converted to the specified type.- Type Parameters:
- T- The type to convert the value to.
- Parameters:
- parser- The parser to use to parse the entry value.
- type- The type to convert the value to.
- Returns:
- This entry converted to the specified type, or Optional.empty()if the entry does not exist.
 
- 
toStringReturns this entry as a string.
- 
asStringReturns this entry as a string.- Returns:
- This entry as a string, or Optional.empty()if the entry does not exist.
 
- 
asStringArrayReturns this entry as a string array.If the value exists, splits the value on commas and returns the values as trimmed strings. - Returns:
- This entry as a string array, or Optional.empty()if the entry does not exist.
 
- 
asIntegerReturns this entry as an integer."K" ,"M" , and"G" can be used to identify kilo, mega, and giga in base 2."k" ,"m" , and"g" can be used to identify kilo, mega, and giga in base 10.Example:- 
      "100K" -> 1024000
- 
      "100M" -> 104857600
- 
      "100k" -> 1000000
- 
      "100m" -> 100000000
 Uses Integer.decode(String)underneath, so any of the following integer formats are supported:- "0x..." 
- "0X..." 
- "#..." 
- "0..." 
 - Returns:
- The value, or Optional.empty()if the value does not exist or the value is empty.
 
- 
      
- 
asBooleanReturns this entry as a parsed boolean.Uses Boolean.parseBoolean(String)to parse value.- Returns:
- The value, or Optional.empty()if the value does not exist or the value is empty.
 
- 
asLongReturns this entry as a long."K" ,"M" ,"G" ,"T" , and"P" can be used to identify kilo, mega, giga, tera, and penta in base 2."k" ,"m" ,"g" ,"t" , and"p" can be used to identify kilo, mega, giga, tera, and p in base 10.Example:- 
      "100K" -> 1024000
- 
      "100M" -> 104857600
- 
      "100k" -> 1000000
- 
      "100m" -> 100000000
 Uses Long.decode(String)underneath, so any of the following integer formats are supported:- "0x..." 
- "0X..." 
- "#..." 
- "0..." 
 - Returns:
- The value, or Optional.empty()if the value does not exist or the value is empty.
 
- 
      
- 
asDoubleReturns this entry as a double.Uses Double.valueOf(String)underneath, so any of the following number formats are supported:- "0x..." 
- "0X..." 
- "#..." 
- "0..." 
 - Returns:
- The value, or Optional.empty()if the value does not exist or the value is empty.
 
- 
asFloatReturns this entry as a float.Uses Float.valueOf(String)underneath, so any of the following number formats are supported:- "0x..." 
- "0X..." 
- "#..." 
- "0..." 
 - Returns:
- The value, or Optional.empty()if the value does not exist or the value is empty.
 
- 
asBytesReturns this entry as a byte array.Byte arrays are stored as encoded strings, typically BASE64, but dependent on the Config.Builder.binaryFormat(BinaryFormat)setting.- Returns:
- The value, or Optional.empty()if the section or key does not exist.
 
- 
asMapReturns this entry as a parsed map.Uses the parser registered on the Configto parse the entry.If the parser is a JSON parser, the starting/trailing "{" /"}" in the value are optional.- Returns:
- The value, or Optional.empty()if the section or key does not exist.
- Throws:
- ParseException- If value could not be parsed.
 
- 
asMapReturns this entry as a parsed map.If the parser is a JSON parser, the starting/trailing "{" /"}" in the value are optional.- Parameters:
- parser- The parser to use to parse the value, or- Optional.empty()to use the parser defined on the config.
- Returns:
- The value, or null if the section or key does not exist.
- Throws:
- ParseException- If value could not be parsed.
 
- 
asListReturns this entry as a parsed list.Uses the parser registered on the Configto parse the entry.If the parser is a JSON parser, the starting/trailing "[" /"]" in the value are optional.- Returns:
- The value, or Optional.empty()if the section or key does not exist.
- Throws:
- ParseException- If value could not be parsed.
 
- 
asListReturns this entry as a parsed list.If the parser is a JSON parser, the starting/trailing "[" /"]" in the value are optional.- Parameters:
- parser- The parser to use to parse the value, or- Optional.empty()to use the parser defined on the config.
- Returns:
- The value, or Optional.empty()if the section or key does not exist.
- Throws:
- ParseException- If value could not be parsed.
 
- 
getKeyReturns the name of this entry.- Returns:
- The name of this entry.
 
- 
getValueReturns the raw value of this entry.- Returns:
- The raw value of this entry.
 
- 
getCommentReturns the same-line comment of this entry.- Returns:
- The same-line comment of this entry.
 
- 
getPreLinesReturns the pre-lines of this entry.- Returns:
- The pre-lines of this entry as an unmodifiable list.
 
- 
getModifiersReturns the modifiers for this entry.- Returns:
- The modifiers for this entry, or null if it has no modifiers.
 
 
-