Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
bcb0656ff5
|
@ -32,14 +32,7 @@ import java.io.PrintStream;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
@ -77,6 +70,7 @@ import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Element extends Base {
|
public class Element extends Base {
|
||||||
|
private static final HashSet<String> extensionList = new HashSet<>(Arrays.asList("extension", "modifierExtension"));
|
||||||
|
|
||||||
public enum SpecialElement {
|
public enum SpecialElement {
|
||||||
CONTAINED, BUNDLE_ENTRY, BUNDLE_OUTCOME, BUNDLE_ISSUES, PARAMETER, LOGICAL;
|
CONTAINED, BUNDLE_ENTRY, BUNDLE_OUTCOME, BUNDLE_ISSUES, PARAMETER, LOGICAL;
|
||||||
|
@ -1070,7 +1064,7 @@ public class Element extends Base {
|
||||||
public Element getExtension(String url) {
|
public Element getExtension(String url) {
|
||||||
if (children != null) {
|
if (children != null) {
|
||||||
for (Element child : children) {
|
for (Element child : children) {
|
||||||
if (Utilities.existsInList(child.getName(), "extension", "modifierExtension")) {
|
if (extensionList.contains(child.getName())) {
|
||||||
String u = child.getChildValue("url");
|
String u = child.getChildValue("url");
|
||||||
if (url.equals(u)) {
|
if (url.equals(u)) {
|
||||||
return child;
|
return child;
|
||||||
|
|
|
@ -301,7 +301,9 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(id, extension);
|
boolean idIsEmpty = id == null || id.isEmpty();
|
||||||
|
boolean extensionIsEmpty = extension == null || extension.size() == 0;
|
||||||
|
return super.isEmpty() && idIsEmpty && extensionIsEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manual code (from Configuration.txt):
|
// Manual code (from Configuration.txt):
|
||||||
|
@ -393,8 +395,12 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE
|
||||||
* @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<Extension> getExtensionsByUrl(String theUrl) {
|
public List<Extension> getExtensionsByUrl(String theUrl) {
|
||||||
org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null");
|
if (theUrl == null) {
|
||||||
ArrayList<Extension> retVal = new ArrayList<Extension>();
|
throw new NullPointerException("theUrl must not be null");
|
||||||
|
} else if (theUrl.length() == 0) {
|
||||||
|
throw new IllegalArgumentException("theUrl must not be empty");
|
||||||
|
}
|
||||||
|
ArrayList<Extension> retVal = new ArrayList<>();
|
||||||
for (Extension next : getExtension()) {
|
for (Extension next : getExtension()) {
|
||||||
if (theUrl.equals(next.getUrl())) {
|
if (theUrl.equals(next.getUrl())) {
|
||||||
retVal.add(next);
|
retVal.add(next);
|
||||||
|
@ -411,7 +417,17 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE
|
||||||
* @param theUrl The URL. Must not be blank or null.
|
* @param theUrl The URL. Must not be blank or null.
|
||||||
*/
|
*/
|
||||||
public boolean hasExtension(String theUrl) {
|
public boolean hasExtension(String theUrl) {
|
||||||
return !getExtensionsByUrl(theUrl).isEmpty();
|
if (extension == null || extension.size() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Extension ext : extension) {
|
||||||
|
if (theUrl.equals(ext.getUrl())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -130,7 +130,8 @@ public abstract class PrimitiveType<T> extends DataType implements IPrimitiveTyp
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return super.isEmpty() && StringUtils.isBlank(getValueAsString());
|
String value = getValueAsString();
|
||||||
|
return !super.isEmpty() || (value != null && value.length() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPrimitive() {
|
public boolean isPrimitive() {
|
||||||
|
|
|
@ -32,13 +32,15 @@ package org.hl7.fhir.r5.utils;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
|
||||||
import org.hl7.fhir.utilities.VersionUtilities;
|
import org.hl7.fhir.utilities.VersionUtilities;
|
||||||
|
|
||||||
|
|
||||||
public class TypesUtilities {
|
public class TypesUtilities {
|
||||||
|
private static final HashSet<String> primitiveTypes = new HashSet<>(Arrays.asList("boolean", "integer", "integer64", "string", "decimal", "uri", "url", "canonical", "base64Binary", "instant", "date", "dateTime", "time", "code", "oid", "id", "uuid", "markdown", "unsignedInt", "positiveInt", "xhtml"));
|
||||||
|
|
||||||
public enum TypeClassification {
|
public enum TypeClassification {
|
||||||
PRIMITIVE, DATATYPE, METADATATYPE, SPECIAL;
|
PRIMITIVE, DATATYPE, METADATATYPE, SPECIAL;
|
||||||
|
@ -170,6 +172,6 @@ public class TypesUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPrimitive(String code) {
|
public static boolean isPrimitive(String code) {
|
||||||
return Utilities.existsInList(code, "boolean", "integer", "integer64", "string", "decimal", "uri", "url", "canonical", "base64Binary", "instant", "date", "dateTime", "time", "code", "oid", "id", "uuid", "markdown", "unsignedInt", "positiveInt", "xhtml");
|
return primitiveTypes.contains(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue