add javadoc around extension mgmt

This commit is contained in:
Grahame Grieve 2020-06-10 12:16:54 +10:00
parent 0c9375aa5b
commit 5efaee2c47
1 changed files with 33 additions and 4 deletions

View File

@ -319,7 +319,15 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE
getExtension().add(ex); 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) { public Extension getExtensionByUrl(String theUrl) {
org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null"); org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null");
ArrayList<Extension> retVal = new ArrayList<Extension>(); ArrayList<Extension> retVal = new ArrayList<Extension>();
@ -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) { public void removeExtension(String theUrl) {
for (int i = getExtension().size()-1; i >= 0; i--) { for (int i = getExtension().size()-1; i >= 0; i--) {
if (theUrl.equals(getExtension().get(i).getUrl())) 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 * Returns an unmodifiable list containing all extensions on this element which
* match the given URL. * match the given URL.
* *
* Note: BackbdoneElements override this to add matching Modifier Extensions too
*
* @param theUrl The URL. Must not be blank or null. * @param theUrl The URL. Must not be blank or null.
* @return an unmodifiable list containing all extensions on this element which * @return an unmodifiable list containing all extensions on this element which match the given URL
* match the given URL
*/ */
public List<Extension> getExtensionsByUrl(String theUrl) { public List<Extension> getExtensionsByUrl(String theUrl) {
org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null"); 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); 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) { public boolean hasExtension(String theUrl) {
return !getExtensionsByUrl(theUrl).isEmpty(); 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 { public String getExtensionString(String theUrl) throws FHIRException {
List<Extension> ext = getExtensionsByUrl(theUrl); List<Extension> ext = getExtensionsByUrl(theUrl);
if (ext.isEmpty()) if (ext.isEmpty())