From d2dc15e2c8d543215ceae87a3219227f3e9217eb Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 7 Apr 2020 14:49:27 +1000 Subject: [PATCH] throw Error when a value is assigned to NamingSystem.url --- .../java/org/hl7/fhir/dstu3/model/MetadataResource.java | 7 +++++++ .../main/java/org/hl7/fhir/dstu3/model/NamingSystem.java | 5 +++++ .../main/java/org/hl7/fhir/r4/model/MetadataResource.java | 8 +++++++- .../src/main/java/org/hl7/fhir/r4/model/NamingSystem.java | 6 ++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/MetadataResource.java b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/MetadataResource.java index 21bac666f..4f6618312 100644 --- a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/MetadataResource.java +++ b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/MetadataResource.java @@ -193,10 +193,15 @@ public abstract class MetadataResource extends DomainResource { * @param value {@link #url} (An absolute URI that is used to identify this metadata resource when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this metadata resource is (or will be) published. The URL SHOULD include the major version of the metadata resource. For more information see [Technical and Business Versions](resource.html#versions).). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value */ public MetadataResource setUrlElement(UriType value) { + checkCanUseUrl(); this.url = value; return this; } + protected void checkCanUseUrl() { + // it's fine + } + /** * @return An absolute URI that is used to identify this metadata resource when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this metadata resource is (or will be) published. The URL SHOULD include the major version of the metadata resource. For more information see [Technical and Business Versions](resource.html#versions). */ @@ -211,6 +216,7 @@ public abstract class MetadataResource extends DomainResource { if (Utilities.noString(value)) this.url = null; else { + checkCanUseUrl(); if (this.url == null) this.url = new UriType(); this.url.setValue(value); @@ -1049,6 +1055,7 @@ public abstract class MetadataResource extends DomainResource { return fhirType()+"["+getUrl()+"]"; } + // end addition } diff --git a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/NamingSystem.java b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/NamingSystem.java index b55158f97..782d43cad 100644 --- a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/NamingSystem.java +++ b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/model/NamingSystem.java @@ -2093,6 +2093,11 @@ public class NamingSystem extends MetadataResource { */ public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS); + @Override + protected void checkCanUseUrl() { + throw new Error("URL cannot be used on NamingSystem"); + } + } diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/MetadataResource.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/MetadataResource.java index 4f1775fe5..435459d96 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/MetadataResource.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/MetadataResource.java @@ -192,11 +192,16 @@ public abstract class MetadataResource extends DomainResource { /** * @param value {@link #url} (An absolute URI that is used to identify this metadata resource when it is referenced in a specification, model, design or an instance; also called its canonical identifier. This SHOULD be globally unique and SHOULD be a literal address at which at which an authoritative instance of this metadata resource is (or will be) published. This URL can be the target of a canonical reference. It SHALL remain the same when the metadata resource is stored on different servers.). This is the underlying object with id, value and extensions. The accessor "getUrl" gives direct access to the value */ - public MetadataResource setUrlElement(UriType value) { + public MetadataResource setUrlElement(UriType value) { + checkCanUseUrl(); this.url = value; return this; } + protected void checkCanUseUrl() { + // it's fine + } + /** * @return An absolute URI that is used to identify this metadata resource when it is referenced in a specification, model, design or an instance; also called its canonical identifier. This SHOULD be globally unique and SHOULD be a literal address at which at which an authoritative instance of this metadata resource is (or will be) published. This URL can be the target of a canonical reference. It SHALL remain the same when the metadata resource is stored on different servers. */ @@ -211,6 +216,7 @@ public abstract class MetadataResource extends DomainResource { if (Utilities.noString(value)) this.url = null; else { + checkCanUseUrl(); if (this.url == null) this.url = new UriType(); this.url.setValue(value); diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/NamingSystem.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/NamingSystem.java index 8b1375ef3..2435ccf06 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/NamingSystem.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/NamingSystem.java @@ -2096,5 +2096,11 @@ public class NamingSystem extends MetadataResource { public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS); + @Override + protected void checkCanUseUrl() { + throw new Error("URL cannot be used on NamingSystem"); + } + + }