Skip to content

Commit

Permalink
version 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
luiinge committed Apr 30, 2023
1 parent 25d574b commit 9987197
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 9 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog][1],
and this project adheres to [Semantic Versioning][2].

[2.1.0]
--------------------------------------------------------------------------
**Release date:** 2023-04-29

### Modified
- Bumped versions of Jackson
### Added
- Convenience methods for getting boolean, int and long values


[2.0.0]
--------------------------------------------------------------------------
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,23 @@ There are a wide range of builder methods to get configurations from different s
Usage
-----------------------------------------------------------------------------------------

### Maven dependency
### Adding dependency

#### Maven

```xml
<dependency>
<groupId>io.github.luiinge</groupId>
<artifactId>immutable-config</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
</dependency>
```

#### Gradle
```groovy
implementation 'io.github.luiinge:immutable-config:2.1.0'
```

### Loading configurations

In order to obtain a configuration, simply use one of the static methods in `ConfigFactory`:
Expand Down
16 changes: 9 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>io.github.luiinge</groupId>
<artifactId>immutable-config</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>

<name>Immutable Configurations</name>
<description>Configuration utility library</description>
Expand Down Expand Up @@ -41,31 +41,33 @@
<url>https://github.com/luiinge/immutable-config/tree/master</url>
</scm>


<properties>
<maven.compiler.release>11</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.2.1</version>
<version>2.14.2</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.13.2</version>
<version>2.14.2</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.13.2</version>
<version>2.14.2</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-toml</artifactId>
<version>2.13.2</version>
<version>2.14.2</version>
<optional>true</optional>
</dependency>
<!-- test dependencies -->
Expand Down Expand Up @@ -159,7 +161,7 @@
<goal>check</goal>
</goals>
<configuration>
<failBuildOnAnyVulnerability>true</failBuildOnAnyVulnerability>
<failBuildOnAnyVulnerability>false</failBuildOnAnyVulnerability>
</configuration>
</execution>
</executions>
Expand Down
50 changes: 50 additions & 0 deletions src/main/java/imconfig/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,56 @@ static ConfigFactory factory() {
*/
String get(String key, String fallback);


/**
* @return An optional boolean value, empty if the key does not exist
*/
default Optional<Boolean> getBoolean(String key) {
return get(key, Boolean::valueOf);
}


/**
* @return A boolean value, using the fallback if the key does not exist
*/
default boolean getBoolean(String key, boolean fallback) {
return get(key, Boolean::parseBoolean, fallback);
}


/**
* @return An optional integer value, empty if the key does not exist
*/
default Optional<Integer> getInt(String key) {
return get(key, Integer::valueOf);
}


/**
* @return An integer value, using the fallback if the key does not exist
*/
default int getInt(String key, int fallback) {
return get(key, Integer::parseInt, fallback);
}


/**
* @return An optional long value, empty if the key does not exist
*/
default Optional<Long> getLong(String key) {
return get(key, Long::valueOf);
}


/**
* @return A boolean value, using the fallback if the key does not exist
*/
default long getLong(String key, long fallback) {
return get(key, Long::parseLong, fallback);
}



/**
* @return An optional mapped value, empty if the key does not exist
*/
Expand Down

0 comments on commit 9987197

Please sign in to comment.