public class YamlFileReader extends Object implements PropertyReader
| Constructor and Description |
|---|
YamlFileReader(@NotNull File file)
Deprecated.
scheduled for removal in favor of Path
|
YamlFileReader(@NotNull Path path)
Constructor.
|
YamlFileReader(@NotNull Path path,
@NotNull Charset charset)
Constructor.
|
YamlFileReader(@NotNull Path path,
@NotNull Charset charset,
boolean splitDotPaths)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(@NotNull String path)
Returns whether a value is present for the given path.
|
@Nullable Boolean |
getBoolean(@NotNull String path)
Returns the value of the given path as a boolean if available.
|
@NotNull Set<String> |
getChildKeys(@NotNull String path)
Returns the direct children of the given path which are available in the file.
|
@Nullable Double |
getDouble(@NotNull String path)
Returns the value of the given path as a double if available.
|
protected @NotNull File |
getFile()
Deprecated.
|
@Nullable Integer |
getInt(@NotNull String path)
Returns the value of the given path as an integer if available.
|
@NotNull Set<String> |
getKeys(boolean onlyLeafNodes)
Returns the keys available in the file.
|
@Nullable List<?> |
getList(@NotNull String path)
Returns the value of the given path as a list if available.
|
@Nullable Object |
getObject(@NotNull String path)
Returns the object at the given path, or null if absent.
|
protected @NotNull Path |
getPath() |
protected @Nullable Map<String,Object> |
getRoot()
Deprecated.
use
getObject("") instead |
@Nullable String |
getString(@NotNull String path)
Returns the value of the given path as a String if available.
|
protected <T> T |
getTypedObject(@NotNull String path,
@NotNull Class<T> clazz)
Gets the object at the given path and safely casts it to the given class's type.
|
protected @Nullable Map<String,Object> |
loadFile(boolean splitDotPaths)
Loads the values of the file.
|
protected @Nullable Map<String,Object> |
normalizeMap(@Nullable Map<Object,Object> map,
boolean splitDotPaths)
Processes the map as read from SnakeYAML and may return a new, adjusted one.
|
public YamlFileReader(@NotNull
@NotNull Path path)
path - the file to loadpublic YamlFileReader(@NotNull
@NotNull Path path,
@NotNull
@NotNull Charset charset)
path - the file to loadcharset - the charset to read the data aspublic YamlFileReader(@NotNull
@NotNull Path path,
@NotNull
@NotNull Charset charset,
boolean splitDotPaths)
path - the file to loadcharset - the charset to read the data assplitDotPaths - whether dots in yaml paths should be split into nested paths@Deprecated public YamlFileReader(@NotNull @NotNull File file)
Path.file - the file to load@Nullable public @Nullable Object getObject(@NotNull @NotNull String path)
PropertyReadergetObject in interface PropertyReaderpath - the path to retrieve the value for@Nullable public @Nullable String getString(@NotNull @NotNull String path)
PropertyReadergetString in interface PropertyReaderpath - the path to retrieve a String for@Nullable public @Nullable Integer getInt(@NotNull @NotNull String path)
PropertyReadergetInt in interface PropertyReaderpath - the path to retrieve an integer for@Nullable public @Nullable Double getDouble(@NotNull @NotNull String path)
PropertyReadergetDouble in interface PropertyReaderpath - the path to retrieve a double for@Nullable public @Nullable Boolean getBoolean(@NotNull @NotNull String path)
PropertyReadergetBoolean in interface PropertyReaderpath - the path to retrieve a boolean for@Nullable public @Nullable List<?> getList(@NotNull @NotNull String path)
PropertyReadergetList in interface PropertyReaderpath - the path to retrieve a list forpublic boolean contains(@NotNull
@NotNull String path)
PropertyReaderProperty.determineValue(PropertyReader) should be favored over
calling this method as it may make more type-aware checks. This method simply returns whether some value
exists under the given path.contains in interface PropertyReaderpath - the path to check@NotNull public @NotNull Set<String> getKeys(boolean onlyLeafNodes)
PropertyReadergetKeys in interface PropertyReaderonlyLeafNodes - true if only the paths of leaf nodes should be returned (no intermediate paths)@NotNull public @NotNull Set<String> getChildKeys(@NotNull @NotNull String path)
PropertyReadergetChildKeys in interface PropertyReaderpath - the path whose direct child paths should be looked up@Nullable protected @Nullable Map<String,Object> loadFile(boolean splitDotPaths)
splitDotPaths - whether compound keys (keys with ".") should be split into nested paths@Nullable protected @Nullable Map<String,Object> normalizeMap(@Nullable @Nullable Map<Object,Object> map, boolean splitDotPaths)
map - the map to normalizesplitDotPaths - whether compound keys (keys with ".") should be split into nested paths@Deprecated @NotNull protected final @NotNull File getFile()
@NotNull protected final @NotNull Path getPath()
@Deprecated @Nullable protected final @Nullable Map<String,Object> getRoot()
getObject("") instead@Nullable
protected <T> T getTypedObject(@NotNull
@NotNull String path,
@NotNull
@NotNull Class<T> clazz)
T - the class typepath - the path to retrieveclazz - the class to cast toCopyright © 2016–2023 The AuthMe Team. All rights reserved.