diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Element.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Element.java index 36c2ace35..21f082ba0 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Element.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Element.java @@ -319,7 +319,15 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE getExtension().add(ex); } - + + /** + * Returns an extension if one (and only one) matches the given URL. + * + * Note: BackbdoneElements override this to look in matching Modifier Extensions too + * + * @param theUrl The URL. Must not be blank or null. + * @return the matching extension, or null + */ public Extension getExtensionByUrl(String theUrl) { org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null"); ArrayList retVal = new ArrayList(); @@ -336,6 +344,13 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE } } + /** + * Remove any extensions that match (by given URL). + * + * Note: BackbdoneElements override this to remove from Modifier Extensions too + * + * @param theUrl The URL. Must not be blank or null. + */ public void removeExtension(String theUrl) { for (int i = getExtension().size()-1; i >= 0; i--) { if (theUrl.equals(getExtension().get(i).getUrl())) @@ -367,9 +382,10 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE * Returns an unmodifiable list containing all extensions on this element which * match the given URL. * + * Note: BackbdoneElements override this to add matching Modifier Extensions too + * * @param theUrl The URL. Must not be blank or null. - * @return an unmodifiable list containing all extensions on this element which - * match the given URL + * @return an unmodifiable list containing all extensions on this element which match the given URL */ public List getExtensionsByUrl(String theUrl) { org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null"); @@ -382,11 +398,24 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE return java.util.Collections.unmodifiableList(retVal); } + /** + * Returns an true if this element has an extension that matchs the given URL. + * + * Note: BackbdoneElements override this to check Modifier Extensions too + * + * @param theUrl The URL. Must not be blank or null. + */ public boolean hasExtension(String theUrl) { return !getExtensionsByUrl(theUrl).isEmpty(); } - + /** + * Returns the value as a string if this element has only one extension that matches the given URL, and that can be converted to a string. + * + * Note: BackbdoneElements override this to check Modifier Extensions too + * + * @param theUrl The URL. Must not be blank or null. + */ public String getExtensionString(String theUrl) throws FHIRException { List ext = getExtensionsByUrl(theUrl); if (ext.isEmpty())