Skip to content

Supports to read properties, yaml file and map them to POJO

Notifications You must be signed in to change notification settings

tvd12/properties-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status Maven Central Javadocs

Synopsis

This project support for interact with properties file

Code Example

1. Read properties file

Properties properties = new BaseFileReader()
    .read("application.properties");

2. Read YAML file

Properties yamlProperties = new BaseFileReader()
    .read("application.yaml");

3. Read properties file with profiles

Properties propertiesAlpha = new MultiFileReader("alpha")
    .read("application.properties");

4. Read YAML file with profiles

Properties propertiesAlpha = new MultiFileReader("alpha")
    .read("application.yaml");

5. Map properties or YAML file to POJO

ApplicationConfig applicationConfigYaml = new PropertiesMapper()
    .reader(new MultiFileReader("alpha"))
    .file("application.yaml")
    .map(ApplicationConfig.class);

6. Use annotation to map

public class Config {
    @Property("n")
    private String name;

    @Property("a")
    private int age;

    @Property("m")
    private long money = 10;
}

7. Use variable in properties file

app.hello=world
app.hi=${app.hello}

8. Use variable in yaml file

app.hello: world
app.hi: ${app.hello}

Motivation

Proprties and YAML are using in a lot of framework and application, so we want to create a library support to read .propertes and YAML file and map them to POJO if you want

Installation

<dependency>
    <groupId>com.tvd12</groupId>
    <artifactId>properties-file</artifactId>
    <version>1.1.8</version>
</dependency>

API Reference

http://www.javadoc.io/doc/com.tvd12/properties-file

Tests

mvn test

Contact us

License

  • Apache License, Version 2.0