public class YamlFileReader extends Object implements PropertyReader
| Constructor and Description |
|---|
YamlFileReader(File file)
Constructor.
|
YamlFileReader(File file,
Charset charset) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(String path)
Returns whether a value is present for the given path.
|
Boolean |
getBoolean(String path)
Returns the value of the given path as a boolean if available.
|
Double |
getDouble(String path)
Returns the value of the given path as a double if available.
|
protected File |
getFile() |
Integer |
getInt(String path)
Returns the value of the given path as an integer if available.
|
Set<String> |
getKeys(boolean onlyLeafNodes)
Returns the keys available in the file.
|
List<?> |
getList(String path)
Returns the value of the given path as a list if available.
|
Object |
getObject(String path)
Returns the object at the given path, or null if absent.
|
protected Map<String,Object> |
getRoot() |
String |
getString(String path)
Returns the value of the given path as a String if available.
|
protected <T> T |
getTypedObject(String path,
Class<T> clazz)
Gets the object at the given path and safely casts it to the given class' type.
|
protected Map<String,Object> |
loadFile()
Loads the values of the file.
|
public YamlFileReader(File file)
file - the file to loadpublic Object getObject(String path)
PropertyReadergetObject in interface PropertyReaderpath - the path to retrieve the value forpublic String getString(String path)
PropertyReadergetString in interface PropertyReaderpath - the path to retrieve a String forpublic Integer getInt(String path)
PropertyReadergetInt in interface PropertyReaderpath - the path to retrieve an integer forpublic Double getDouble(String path)
PropertyReadergetDouble in interface PropertyReaderpath - the path to retrieve a double forpublic Boolean getBoolean(String path)
PropertyReadergetBoolean in interface PropertyReaderpath - the path to retrieve a boolean forpublic List<?> getList(String path)
PropertyReadergetList in interface PropertyReaderpath - the path to retrieve a list forpublic boolean contains(String path)
PropertyReaderProperty.isPresent(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 checkpublic Set<String> getKeys(boolean onlyLeafNodes)
PropertyReadergetKeys in interface PropertyReaderonlyLeafNodes - true if only the paths of leaf nodes should be returned (no intermediate paths)protected Map<String,Object> loadFile()
protected final File getFile()
@Nullable protected <T> T getTypedObject(String path, Class<T> clazz)
T - the class typepath - the path to retrieveclazz - the class to cast toCopyright © 2016–2018 The AuthMe Team. All rights reserved.