Class YamlLoader
- java.lang.Object
-
- app.coronawarn.server.services.distribution.assembly.appconfig.YamlLoader
-
public class YamlLoader extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
loadYamlIntoClass(String path, Class<T> classType)
Reads the class path resource yaml at given path and deserializes into an instance of the given object.static <T extends com.google.protobuf.Message.Builder>
TloadYamlIntoProtobufBuilder(String path, Class<T> builderType)
Returns a protobufmessage builder
of the specified type, whose fields have been set to the corresponding values from the yaml file at the specified path.
-
-
-
Method Detail
-
loadYamlIntoProtobufBuilder
public static <T extends com.google.protobuf.Message.Builder> T loadYamlIntoProtobufBuilder(String path, Class<T> builderType) throws UnableToLoadFileException
Returns a protobufmessage builder
of the specified type, whose fields have been set to the corresponding values from the yaml file at the specified path.- Parameters:
path
- The absolute path of the yaml file within the class path.builderType
- The specificMessage.Builder
implementation that will be returned.- Returns:
- A prepared protobuf
message builder
of the specified type. - Throws:
UnableToLoadFileException
- if either the file access or subsequent yaml parsing fails.
-
loadYamlIntoClass
public static <T> T loadYamlIntoClass(String path, Class<T> classType) throws UnableToLoadFileException
Reads the class path resource yaml at given path and deserializes into an instance of the given object. The yaml naming convention is expected to be dash based ("an-example-property"), but the method will translate this to a camelCase class property.- Throws:
UnableToLoadFileException
-
-