Skip to content

Commit

Permalink
add support for default value
Browse files Browse the repository at this point in the history
  • Loading branch information
cdimascio committed Sep 19, 2020
1 parent 4057ea1 commit 4c864db
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ script: mvn clean test
sudo: false
after_success:
# - mvn clean test jacoco:report coveralls:report
- mvn clean test
- mvn clean test jacoco:report
51 changes: 28 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>io.github.cdimascio</groupId>
<artifactId>dotenv-java</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>

<licenses>
<license>
Expand Down Expand Up @@ -57,7 +57,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<maven.source.plugin>3.0.1</maven.source.plugin>
<maven.javadoc.plugin>3.0.0</maven.javadoc.plugin>
<maven.javadoc.plugin>3.2.0</maven.javadoc.plugin>
<bintray.subject>cdimascio</bintray.subject>
<bintray.repo>maven</bintray.repo>
<bintray.package>dotenv-java</bintray.package>
Expand Down Expand Up @@ -113,10 +113,13 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven.javadoc.plugin}</version>
<configuration>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -126,27 +129,29 @@
</execution>
</executions>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.jacoco</groupId>-->
<!-- <artifactId>jacoco-maven-plugin</artifactId>-->
<!-- <version>0.7.6.201602180812</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>prepare-agent</id>-->
<!-- <goals>-->
<!-- <goal>prepare-agent</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.eluder.coveralls</groupId>-->
<!-- <artifactId>coveralls-maven-plugin</artifactId>-->
<!-- <version>4.3.0</version>-->
<!-- <configuration>-->
<!-- <repoToken>i3Bl4av26PMqZNekY8X3Jt7t6YhwFXKFu</repoToken>-->
<!-- </configuration>-->
<!-- </plugin>-->

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- <plugin>-->
<!-- <groupId>org.eluder.coveralls</groupId>-->
<!-- <artifactId>coveralls-maven-plugin</artifactId>-->
<!-- <version>4.3.0</version>-->
<!-- <configuration>-->
<!-- <repoToken>i3Bl4av26PMqZNekY8X3Jt7t6YhwFXKFu</repoToken>-->
<!-- </configuration>-->
<!-- </plugin>-->
</plugins>
</build>

Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/github/cdimascio/dotenv/Dotenv.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ static Dotenv load() {
Set<DotenvEntry> entries();
Set<DotenvEntry> entries(EntriesFilter filter);
String get(String key);
String get(String key, String defaultValue);
}
6 changes: 6 additions & 0 deletions src/main/java/io/github/cdimascio/dotenv/DotenvBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ public String get(String key) {
return value != null ? value : map.get(key);
}

@Override
public String get(String key, String defaultValue) {
var value = this.get(key);
return value != null ? value : defaultValue;
}

private Map<String, String> buildEntries() {
var envMap = new HashMap<String, String>();
System.getenv().forEach(envMap::put);
Expand Down

0 comments on commit 4c864db

Please sign in to comment.