Skip to content

Commit

Permalink
[1.4.1-SNAPSHOT]
Browse files Browse the repository at this point in the history
GsonFactory#builder and GsonFactory#builderJavaISO added
  • Loading branch information
GoodforGod committed Mar 13, 2022
1 parent 97f434c commit 6269cad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
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-SNAPSHOT


##### 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 6269cad

Please sign in to comment.