YamlConfig

  
Type🔵 Class
Packageio.github.mrtesz.teszcore.config
GitHubYamlConfig.java
ImplementsCopyable<YamlConfig>
SubclassesYamlConfig.Builder

Description

A class for managing YAML files


Building

Build a new YamlConfig by building a new YamlConfig.Builder instance and executing YamlConfig.Builder#build()


Methods

builder

static YamlConfig.Builder builder();

Generate a YamlConfig Builder

Returns: YamlConfig.Builder — A new Builder


load

void load();

Creates the file or directory if not existent and loads the data of the YAML file

Throws: YamlConfigException when an I/O error occurs


save

void save();
void save(Charset cs);

Saves the current data to the YAML file

ParameterTypeAnnotationsDescription
cs<abbr title=java.nio.charset.Charset>Charset</abbr>@NotNull(optional) cs of OutputStreamWriter(OutputStream, Charset) Default: StandardCharsets.UTF_8

Throws: YamlConfigException when an I/O error occurs


addDefault

void addDefault(String path, Object value);

Add a new entry to the defaults map

ParameterTypeAnnotationsDescription
pathString@NotNullPath
valueObject-Value

setDefault

void setDefault(String path, Object value);

Saves a value to the YAML file if the path is empty

ParameterTypeAnnotationsDescription
pathString@NotNullPath
valueObject-Value

set

void set(@NotNull String path, Object value);

Sets a value in the YAML file

ParameterTypeAnnotationsDescription
pathString@NotNullPath
valueObject@NullableValue

contains

boolean contains(@NotNull String path);

See if a path contains a value

ParameterTypeAnnotationsDescription
pathString@NotNullPath

Returns: boolean — true if the path contains a value


exists

boolean exists();

See if the YAML file exists

Returns: boolean — true if the YAML file exists


getRaw

Map<String, Object> getRaw();

Get the raw data of the YAML

Returns: Map<String, Object> — raw data of the YAML


setData

void setData(Map<String, Object> data);

Set the raw data (does not save automatically)


getAllPaths

public Set<String> getAllPaths();

Collect all paths of the YAML

Returns: Set<String> — all paths in the config (e.g. database.host, database.port)


getPaths

Set<String> getPaths(@NotNull String parent);

Return all paths under the given parent path

ParameterTypeAnnotationsDescription
parentString@NotNullPath to the parent section (e.g. database)

Returns: Set<String> — all paths under the given parent path (e.g. database.host, database.port), or empty if the path does not exist or is not a section


copy

implemented from Copyable

T: YamlConfig


YAML Methods

ParameterAnnotationsDescription
path@NotNullPath
def-(optional) Default value, when no value is found
MethodReturns
get(path)Object value at path, or null if not found
getString(path)String value at path, or null if not found
getString(path, def)String value at path, or def if not found
getInt(path)int value at path, or 0 if not found or not a Number
getInt(path, def)int value at path, or def if not found or not a Number
getIntOrNull(path)Integer value at path, or null if not found or not a Number
getLong(path)long value at path, or 0 if not found or not a Number
getLong(path, def)long value at path, or def if not found or not a Number
getLongOrNull(path)Long value at path, or null if not found or not a Number
getFloat(path)float value at path, or 0 if not found or not a Number
getFloat(path, def)float value at path, or def if not found or not a Number
getFloatOrNull(path)Float value at path, or null if not found or not a Number
getShort(path)short value at path, or 0 if not found or not a Number
getShort(path, def)short value at path, or def if not found or not a Number
getShortOrNull(path)Short value at path, or null if not found or not a Number
getDouble(path)double value at path, or 0 if not found or not a Number
getDouble(path, def)double value at path, or def if not found or not a Number
getDoubleOrNull(path)Double value at path, or null if not found or not a Number
getBoolean(path)boolean value at path, or false if not found or not a Boolean
getBoolean(path, def)boolean value at path, or def if not found or not a Boolean
getBooleanOrNull(path)Boolean value at path, or null if not found or not a Boolean
getStringList(path)List<String> at path, or empty if not found or not a List
getStringList(path, def)List<String> at path, or def if not found or not a List
getStringList(path)List<String> at path, or null if not found or not a List


Table of contents


Back to top

Copyright © 2026 Mr_Tesz. All rights reserved

This site uses Just the Docs, a documentation theme for Jekyll.