-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1417 from Sloeber/#1339_Add_deserialisation_clases
#1339 add deserialisation clases
- Loading branch information
Showing
88 changed files
with
5,985 additions
and
5,796 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
io.sloeber.core/src/io/sloeber/core/Gson/GsonConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.sloeber.core.Gson; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
||
import io.sloeber.core.api.VersionNumber; | ||
|
||
public class GsonConverter { | ||
public static String getSafeString(JsonObject jsonObject, String fieldName) { | ||
JsonElement field = jsonObject.get(fieldName); | ||
if (field == null) { | ||
return "no info found in file"; //$NON-NLS-1$ | ||
} | ||
return field.getAsString(); | ||
|
||
} | ||
|
||
public static VersionNumber getSafeVersion(JsonObject jsonObject, String fieldName) { | ||
JsonElement field = jsonObject.get(fieldName); | ||
if (field == null) { | ||
return new VersionNumber("no version number provided"); //$NON-NLS-1$ | ||
} | ||
return new VersionNumber(field.getAsString()); | ||
|
||
} | ||
|
||
public static String getSafeString(JsonObject jsonObject, String fieldName1, String fieldName2) { | ||
JsonElement field = jsonObject.get(fieldName1); | ||
if (field != null) { | ||
field = field.getAsJsonObject().get(fieldName2); | ||
if (field != null) { | ||
return field.getAsString(); | ||
} | ||
} | ||
|
||
return "no info found in file"; //$NON-NLS-1$ | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.