Skip to content

Commit

Permalink
Merge pull request #9 from GoodforGod/dev
Browse files Browse the repository at this point in the history
[1.4.1]
  • Loading branch information
GoodforGod authored Mar 13, 2022
2 parents 97f434c + 2222450 commit f489584
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ Gson configuration and serializers/deserializers for Date/Time in [java.time.*](
## Dependency :rocket:
**Gradle**
```groovy
implementation "io.goodforgod:gson-configuration:1.4.0"
implementation "io.goodforgod:gson-configuration:1.4.1"
```

**Maven**
```xml
<dependency>
<groupId>io.goodforgod</groupId>
<artifactId>gson-configuration</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
groupId=io.goodforgod
artifactId=gson-configuration
artifactVersion=1.4.0
artifactVersion=1.4.1


##### GRADLE #####
Expand Down
19 changes: 17 additions & 2 deletions src/main/java/io/goodforgod/gson/configuration/GsonFactory.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.goodforgod.gson.configuration;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.InputStream;
import java.util.Properties;

Expand All @@ -23,26 +24,40 @@ public class GsonFactory {
* @return Gson built with {@link GsonConfiguration#of()} as base
*/
public Gson build() {
return builder().create();
}

/**
* @return Gson built with {@link GsonConfiguration#of()} as base
*/
public GsonBuilder builder() {
if (properties == null)
this.properties = getProperties();

if (configuration == null)
this.configuration = GsonConfiguration.ofProperties(properties);

return configuration.builder().create();
return configuration.builder();
}

/**
* @return Gson built with {@link GsonConfiguration#ofJavaISO()} as base
*/
public Gson buildJavaISO() {
return builderJavaISO().create();
}

/**
* @return Gson built with {@link GsonConfiguration#ofJavaISO()} as base
*/
public GsonBuilder builderJavaISO() {
if (properties == null)
this.properties = getProperties();

if (configurationJavaISO == null)
this.configurationJavaISO = GsonConfiguration.ofPropertiesJavaISO(properties);

return configurationJavaISO.builder().create();
return configurationJavaISO.builder();
}

private Properties getProperties() {
Expand Down

0 comments on commit f489584

Please sign in to comment.