com.github.sparkmuse:properties-mapper

This project is to map yaml properties to java beans.

License

License

GroupId

GroupId

com.github.sparkmuse
ArtifactId

ArtifactId

properties-mapper
Last Version

Last Version

1.1.10
Release Date

Release Date

Type

Type

jar
Description

Description

com.github.sparkmuse:properties-mapper
This project is to map yaml properties to java beans.
Project URL

Project URL

https://github.com/sparkmuse/properties-mapper
Source Code Management

Source Code Management

https://github.com/sparkmuse/properties-mapper

Download properties-mapper

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.sparkmuse/properties-mapper/ -->
<dependency>
    <groupId>com.github.sparkmuse</groupId>
    <artifactId>properties-mapper</artifactId>
    <version>1.1.10</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.sparkmuse/properties-mapper/
implementation 'com.github.sparkmuse:properties-mapper:1.1.10'
// https://jarcasting.com/artifacts/com.github.sparkmuse/properties-mapper/
implementation ("com.github.sparkmuse:properties-mapper:1.1.10")
'com.github.sparkmuse:properties-mapper:jar:1.1.10'
<dependency org="com.github.sparkmuse" name="properties-mapper" rev="1.1.10">
  <artifact name="properties-mapper" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.sparkmuse', module='properties-mapper', version='1.1.10')
)
libraryDependencies += "com.github.sparkmuse" % "properties-mapper" % "1.1.10"
[com.github.sparkmuse/properties-mapper "1.1.10"]

Dependencies

compile (3)

Group / Artifact Type Version
org.yaml : snakeyaml jar 1.25
org.slf4j : slf4j-api jar 1.7.30
org.slf4j : slf4j-simple jar 1.7.30

test (3)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.12
org.junit.jupiter : junit-jupiter jar 5.6.0
org.assertj : assertj-core jar 3.13.2

Project Modules

There are no modules declared in this project.

Properties Mapper

Small project to easily map properties in yaml to Java POJOs

Install

Add the bellow dependency to your maven project

<dependency>
    <groupId>com.github.sparkmuse</groupId>
    <artifactId>properties-mapper</artifactId>
    <version>${version}</version>
</dependency>

or to gradle

compile 'com.github.sparkmuse:properties-mapper:${version}'

The version can be obtained by going to the link https://mvnrepository.com/artifact/com.github.sparkmuse/property-mapper

Usage

Create the java POJO to be bound to the yaml properties and annotate it

@Property(source="person.yaml", prefix = "person")
public class Person {
    private String name;
    private Long age;

    // No arguments constructor
    
    // Standard getters and setters
}

And on the yaml file person.yaml

person:
  name: John
  age: 25

An instance of the property can be accessed as follows

public class Main {
    public static void main(String[] args) {
        
        // Get an instance of person with all values filled in
        Optional<Person> person = Binder.get(Person.class);
        
        if (person.isPresent()) {
            System.out.println("I have created a person!");
        }
    }
}

Description

  • Source: This is the source of the file containing the values for the mapping.
  • Prefix: The prefix where the values can be accessed. It can be empty if the elements are in the top level yaml document.

Versions

Version
1.1.10
1.1.9