Class YamlLoader


  • public class YamlLoader
    extends Object
    • Method Detail

      • loadYamlIntoProtobufBuilder

        public static <T extends com.google.protobuf.Message.Builder> T loadYamlIntoProtobufBuilder​(String path,
                                                                                                    Class<T> builderType)
                                                                                             throws UnableToLoadFileException
        Returns a protobuf message 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 specific Message.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