diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java index bd8de316f..27470a4cd 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java @@ -170,4 +170,28 @@ public class VersionUtilities { return ok; } + public static String incMajorVersion(String v) { + assert isSemVer(v); + int[] parts = splitParts(v); + return Integer.toString(parts[0]+1)+".0.0"; + } + + public static String incMinorVersion(String v) { + assert isSemVer(v); + int[] parts = splitParts(v); + return Integer.toString(parts[0])+"."+Integer.toString(parts[1]+1)+".0"; + } + + public static String incPatchVersion(String v) { + assert isSemVer(v); + int[] parts = splitParts(v); + return Integer.toString(parts[0])+"."+Integer.toString(parts[1])+"."+Integer.toString(parts[2]+1); + } + + private static int[] splitParts(String v) { + String[] p = v.split("\\."); + int[] i = new int[] {Integer.parseInt(p[0]),Integer.parseInt(p[1]),Integer.parseInt(p[2])}; + return i; + } + } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JSONUtil.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JSONUtil.java index 301574ea7..425fffef9 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JSONUtil.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JSONUtil.java @@ -77,6 +77,11 @@ public class JSONUtil { return e == null || e instanceof JsonNull ? null : e.getAsString(); } + public static boolean bool(JsonObject json, String name) { + JsonElement e = json.get(name); + return e == null || e instanceof JsonNull ? false : e.getAsBoolean(); + } + public static String str(JsonObject json, String name1, String name2) { JsonElement e = json.get(name1); if (e == null)