Typesafe Config Yaml provider

A ConfigProvider implementation that allows use of yaml files with typesafe config (POC version)

License

License

Categories

Categories

IDE Development Tools config Application Layer Libs Configuration
GroupId

GroupId

com.jamesratzlaff
ArtifactId

ArtifactId

typesafe-config-yaml-provider
Last Version

Last Version

2019.09.16
Release Date

Release Date

Type

Type

jar
Description

Description

Typesafe Config Yaml provider
A ConfigProvider implementation that allows use of yaml files with typesafe config (POC version)
Project URL

Project URL

https://github.com/jamesratzlaff/typesafe-config-yaml-provider
Source Code Management

Source Code Management

http://github.com/jamesratzlaff//typesafe-config-yaml-provider/tree/master

Download typesafe-config-yaml-provider

How to add to project

<!-- https://jarcasting.com/artifacts/com.jamesratzlaff/typesafe-config-yaml-provider/ -->
<dependency>
    <groupId>com.jamesratzlaff</groupId>
    <artifactId>typesafe-config-yaml-provider</artifactId>
    <version>2019.09.16</version>
</dependency>
// https://jarcasting.com/artifacts/com.jamesratzlaff/typesafe-config-yaml-provider/
implementation 'com.jamesratzlaff:typesafe-config-yaml-provider:2019.09.16'
// https://jarcasting.com/artifacts/com.jamesratzlaff/typesafe-config-yaml-provider/
implementation ("com.jamesratzlaff:typesafe-config-yaml-provider:2019.09.16")
'com.jamesratzlaff:typesafe-config-yaml-provider:jar:2019.09.16'
<dependency org="com.jamesratzlaff" name="typesafe-config-yaml-provider" rev="2019.09.16">
  <artifact name="typesafe-config-yaml-provider" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.jamesratzlaff', module='typesafe-config-yaml-provider', version='2019.09.16')
)
libraryDependencies += "com.jamesratzlaff" % "typesafe-config-yaml-provider" % "2019.09.16"
[com.jamesratzlaff/typesafe-config-yaml-provider "2019.09.16"]

Dependencies

compile (1)

Group / Artifact Type Version
org.yaml : snakeyaml jar 1.25

provided (1)

Group / Artifact Type Version
com.typesafe : config jar 3.1.5-RC1-SNAPSHOT

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

typesafe-config-yaml-provider

A ConfigProvider implementation that allows for yaml files to be used with the typesafe config library

Simply include this library in your classpath if you are using the version of typesafe config that has the SPI feature and you should be able to load yml config files like you would any other config file.

You can add it to your maven project by inclduing the dependency

<dependency>
  <groupId>com.jamesratzlaff</groupId>
  <artifactId>typesafe-config-yaml-provider</artifactId>
  <version>2019.09.16</version>
</dependency>

For other build systems go here to to get what you need to include this library

Including a file within your yml can be done by tagging the value of an item with !include

This libaray is currently in a POC stage

This was developed to show the flexibility of the new SPI feature for typesafe config. That said the code is not very pretty right now as well as javadoc and unit tests being pretty much non-existant. So throw some caution to the wind before you consider using this in a production environment.


Known limitations

Currently for a mulidoc-file things are a little wonky when it comes to using substitutions/placeholders to reference other values within the file. Also for multi-doc files, each stream with in the file is stored in a ConfigList with the key of "---" (or you can use the String constant YAML_CONF.MULTI_DOC_KEY )

Multi-doc file example

Let's say you have a multi-doc yaml file named 'hello.yml' similar to the following:

item_a: hello
item_b:
    - is
    - it
    - me
---
item_a: you're
looking: 4

Loading it is exactly the same as loading any other typesafe config file (the SPI stuff takes care of everything for you)

Config helloConfig = ConfigFactory.load("hello");

Since this is a multi-doc yaml file there is a slight difference in retrieving values (for the time being) than what you would normally would do with a single-doc file (which behaves exactly the same as a standard Config object loaded from a conf,json, or properties file)

to retrieve item_a in the first document stream you'd use

helloConfig.getConfigList("---").get(0).getString("item_a");
//returns the string value hello

to retrieve item_a in the second document stream you'd use

helloConfig.getConfigList("---").get(1).getString("item_a");
//returns the string value you're

Versions

Version
2019.09.16